Android ShowDivider不工作
我试图在我的文本视图和按钮之间放置分隔符,但什么都看不见。这是我的密码:Android ShowDivider不工作,android,android-layout,Android,Android Layout,我试图在我的文本视图和按钮之间放置分隔符,但什么都看不见。这是我的密码: <RelativeLayout 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"
<RelativeLayout 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:id="@+id/quizid1"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Quiz"
android:showDividers="middle"
android:divider="?android:dividerHorizontal"
>
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="@string/quiz_intro"
android:textSize="33sp"
android:textStyle="bold"
android:textColor="@color/holo_blue_dark" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv1"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="50dp"
android:text="@string/quiz_intro2" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp"
android:text="@string/quiz_intro3" />
<Button
android:id="@+id/button1"
style="?android:borderlessButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="@string/go_btn" />
</RelativeLayout>
我使用的是API 14,所以我认为这不是问题所在。我在应用程序中使用了全息暗主题。即使我尝试使用按钮栏样式,它会自动添加分隔符,但也不会创建分隔符。
可能是什么问题?
谢谢通过在
RelativeLayout
中设置分隔符,您想做什么?
分隔符是为列表视图定义的,但不是为相对值定义的
如果要在布局中分隔视图,只需创建分隔视图(在布局文件夹中),并将其包含在父布局中:
水平分隔器:
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/divider_color" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/divider_color" />
垂直分隔带:
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/divider_color" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/divider_color" />
然后:
<include layout="@layout/divider_horizontal" />
是的,我知道listview中使用了分隔符。但它们也可以用于相对布局,以防我使用无边界按钮之类的东西来划分触摸区域。我认为我使用的代码是用于使用全息主题提供的默认分隔符,而不是创建我自己的分隔符,因此它的功能应该与您的答案类似。@ShivamBhalla您可以使用线性布局并显示分隔符。它也适用于api 11及以上版本。@Raghunandan我能不能用相对布局来完成它?是的,我的api级别是14,所以这不会是一个问题。@ShivamBhalla从我在文档中看到的情况来看,它看起来是否定的,除非我在文档中遗漏了一些东西。和线性布局@ShivamBhalla使用线性布局,它将看起来像。为了清楚起见,如果你需要,我可以把它作为一个答案发布。