我有一个TextView
可以正常工作,但是如果我尝试在TextView
中显示RelativeLayout
则不会显示。(“ //本节的开头和结尾”)
我的XML
文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:materialdesign="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFF"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/relativeLayoutMain"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.gc.materialdesign.views.ScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/relativeLayoutContent">
<RelativeLayout
android:id="@+id/relativeLayoutContainer"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.gc.materialdesign.views.LayoutRipple
android:id="@+id/itemSimple"
android:layout_width="fill_parent"
android:layout_height="64dp"
android:background="#FFF"
android:clickable="true">
<!--this section - begin-->
<RelativeLayout
android:layout_width="90dp"
android:layout_height="25dp"
android:layout_alignParentRight="true"
android:background="#e91e63"
android:paddingBottom="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:gravity="center_horizontal"
android:layout_marginRight="7dp"
android:text="sample text"
android:textColor="#727272"
android:textSize="17dp"/>
</RelativeLayout>
<!--this section - end-->
</com.gc.materialdesign.views.LayoutRipple>
</RelativeLayout>
</com.gc.materialdesign.views.ScrollView>
</RelativeLayout>
</LinearLayout>
如果我想让此代码工作,我必须为
width
和height
的RelativeLayout
定义更多的空间,但是我不想要。我希望我的RelativeLayout
与我指定的width
和height
相同。谢谢...
最佳答案
您的RelativeLayout
的height
为25dp
,而padding
为20dp
。意味着只剩下5dp
文本-不足以显示字符。您需要减小padding
或增大height
。
<!--this section - begin-->
<RelativeLayout
android:layout_width="90dp"
android:layout_height="25dp" <--------------------------------
android:layout_alignParentRight="true"
android:background="#e91e63"
android:paddingBottom="20dp"> <--------------------------------
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:gravity="center_horizontal"
android:layout_marginRight="7dp"
android:text="sample text"
android:textColor="#727272"
android:textSize="17dp"/>
</RelativeLayout>
<!--this section - end-->