TextView背景不显示
TextView background not displaying
我一直在开发应用程序,但遇到了问题。
我正在尝试让带有背景的文本视图移动到当前屏幕上方。预览正确呈现它,但是模拟器和我的设备都没有显示它。
这是我的代码 -
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:paddingBottom="0dp" tools:context=".Inspection"
android:baselineAligned="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false">
<fragment
android:id="@+id/nativeuser_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.aadevs.thetabapp.NativeUserFragment"
android:layout_weight="0.5"
tools:layout="@layout/fragment_nativeuser" />
<fragment
android:id="@+id/otheruser_fragment"
android:name="com.aadevs.thetabapp.OtherUserFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
tools:layout="@layout/fragment_otheruser" />
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:paddingBottom="60dp"
android:paddingTop="60dp"
android:background="@drawable/debtcircle">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hey there"
android:layout_gravity="center"/>
</RelativeLayout>
这是我的可绘制债务圈代码 -
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring">
<stroke
android:width="2px"/>
<solid android:color="#FFFFFF"/>
这是不同的渲染图(预览、模拟器和设备)
如您所见,预览工作正常,但模拟器和设备未按预期工作。
有人可以帮助我吗?
你的 drawable 有问题....你应该使用下面的 drawable...
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke
android:width="2dp"
android:color="strokeColorHere"/>
<solid android:color="#FFFFFF"/>
</shape>
如果需要,请提供描边颜色...直接使用...
我一直在开发应用程序,但遇到了问题。 我正在尝试让带有背景的文本视图移动到当前屏幕上方。预览正确呈现它,但是模拟器和我的设备都没有显示它。 这是我的代码 -
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:paddingBottom="0dp" tools:context=".Inspection"
android:baselineAligned="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false">
<fragment
android:id="@+id/nativeuser_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.aadevs.thetabapp.NativeUserFragment"
android:layout_weight="0.5"
tools:layout="@layout/fragment_nativeuser" />
<fragment
android:id="@+id/otheruser_fragment"
android:name="com.aadevs.thetabapp.OtherUserFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
tools:layout="@layout/fragment_otheruser" />
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:paddingBottom="60dp"
android:paddingTop="60dp"
android:background="@drawable/debtcircle">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hey there"
android:layout_gravity="center"/>
</RelativeLayout>
这是我的可绘制债务圈代码 -
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring">
<stroke
android:width="2px"/>
<solid android:color="#FFFFFF"/>
这是不同的渲染图(预览、模拟器和设备)
如您所见,预览工作正常,但模拟器和设备未按预期工作。 有人可以帮助我吗?
你的 drawable 有问题....你应该使用下面的 drawable...
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke
android:width="2dp"
android:color="strokeColorHere"/>
<solid android:color="#FFFFFF"/>
</shape>
如果需要,请提供描边颜色...直接使用...