【发布时间】:2015-02-23 18:58:03
【问题描述】:
我有一个正常工作的TextView,但如果我尝试在RelativeLayout 中显示TextView,它不会显示。(“//本节开始和结束”)
我的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>
如果我想让这段代码正常工作,我必须为RelativeLayout 中的width 和height 定义更多空间,但我不想要。我希望我的 RelativeLayout 与我指定的 width 和 height 相同。
谢谢...
【问题讨论】:
-
对于文本视图,尝试将宽度和高度设置为
match_parent。看看会发生什么 -
在Relativelayout中添加
android:layout_below="@id/itemSimpleJelly" -
@Ranjith 似乎
RelativeLayout在自定义视图内,ID 为itemSimpleJelly。
标签: android xml textview android-relativelayout