Android 如何在一些线性布局之间画线?
我想创建一个布局,如下图所示 我有四个线性布局,我想分开他们与黑色线相同的图片 我怎样才能创造这个Android 如何在一些线性布局之间画线?,android,Android,我想创建一个布局,如下图所示 我有四个线性布局,我想分开他们与黑色线相同的图片 我怎样才能创造这个 在水平布局之间添加此选项 <View android:layout_width="5dp" android:layout_height=“match_parent” android:paddingTop=“16dp” android:paddingBottom=“16dp" android:background=“@android:color/black”/> 在水平布局之间添加此选
在水平布局之间添加此选项
<View
android:layout_width="5dp"
android:layout_height=“match_parent”
android:paddingTop=“16dp”
android:paddingBottom=“16dp"
android:background=“@android:color/black”/>
在水平布局之间添加此选项
<View
android:layout_width="5dp"
android:layout_height=“match_parent”
android:paddingTop=“16dp”
android:paddingBottom=“16dp"
android:background=“@android:color/black”/>
如果您只想使用布局,您可以制作一个框架布局,其中包含层布局,然后有两个垂直和水平布局,然后添加布局。我认为这可能是你正在寻找的,因为这将使线条凌驾于其他视图之上
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<YOUR LAYOUT HERE/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1">
<View
android:layout_width="fill_parent"
android:layout_height="5dp"
android:layout_gravity="center_vertical"
android:layout_margin="40dp"
android:background="#ff000000" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1">
<View
android:layout_width="fill_parent"
android:layout_height="5dp"
android:layout_gravity="center_vertical"
android:layout_margin="40dp"
android:background="#ff000000" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_horizontal">
<View
android:layout_width="5dp"
android:layout_height="fill_parent"
android:layout_margin="40dp"
android:background="#ff000000" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_horizontal">
<View
android:layout_width="5dp"
android:layout_height="fill_parent"
android:layout_margin="40dp"
android:background="#ff000000" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
如果您只想使用布局,您可以制作一个框架布局,其中包含层布局,然后有两个垂直和水平布局,然后添加布局。我认为这可能是你正在寻找的,因为这将使线条凌驾于其他视图之上
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<YOUR LAYOUT HERE/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1">
<View
android:layout_width="fill_parent"
android:layout_height="5dp"
android:layout_gravity="center_vertical"
android:layout_margin="40dp"
android:background="#ff000000" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1">
<View
android:layout_width="fill_parent"
android:layout_height="5dp"
android:layout_gravity="center_vertical"
android:layout_margin="40dp"
android:background="#ff000000" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_horizontal">
<View
android:layout_width="5dp"
android:layout_height="fill_parent"
android:layout_margin="40dp"
android:background="#ff000000" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center_horizontal">
<View
android:layout_width="5dp"
android:layout_height="fill_parent"
android:layout_margin="40dp"
android:background="#ff000000" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
但这不会与他以前的布局重叠吗?这只会把他们推到一边,会有背景显示通过有填充的地方,但这不会重叠他以前的布局吗?它只会把它们推到一边,在有填充的地方会有背景显示,一个9补丁集作为容器的背景可能会很好地工作。一个9补丁集作为容器的背景可能会很好地工作。这很好。但是我有四个不同的线性布局,其中任何一个都可以点击(通过单击每种颜色打开一个活动)。在您的视图中,只有两个线性布局(顶部和底部),在执行此操作时,它们应该仍然可以单击,但不起作用:(在每个线性布局中,我都使用Id和clickable属性,但顶部的两个框都显示相同的活动,底部的两个框都显示活动。我如何修复它们?尝试将android:clickable设置为false,这很好。但我有四个不同的线性布局,其中任何一个都可以单击。)(通过单击每种颜色打开一个活动)。在您的视图中,只有两个线性布局(顶部和底部),在执行此操作时,它们应该仍然可以单击,但不起作用:(在每个线性布局中,我都使用Id和clickable属性,但顶部的两个框都显示相同的活动,底部的两个框都显示活动。我如何修复它们?尝试将android:clickable设置为false(非布局的所有内容)