我想创建附加图像中出现的sudo -u solr ./bin/solr create -c mycore
,但我无法,或者它移动或我重叠,我不适合宽度和高度的完美播放。我想要一个水平Layout
,我将放入一个LinerLayout,它是红色的,4个橙色的矩形(我试图listview
将是按钮或{{ 1}}我会把它放进去,但我无法做到。
我试图放Relative
并且在其中我已经可以使用imagebutton
更多地玩了但是我总是将自己置于左上角并且没有办法将它们移动到向右或向下,我希望一切都是正方形的。做过类似或类似事情的人?
我的代码,但我可以用橙色和红色矩形来实现我的图像。
FrameLayout
答案 0 :(得分:1)
试试这个布局:
<?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="vertical"
android:padding="5dp"
android:weightSum="5">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/border"
android:orientation="horizontal">
<ListView
android:id="@+id/list_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:orientation="horizontal"
android:weightSum="2">
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/border"
android:src="@mipmap/ic_launcher" />
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/border"
android:src="@mipmap/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:orientation="horizontal"
android:weightSum="2">
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/border"
android:src="@mipmap/ic_launcher" />
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/border"
android:src="@mipmap/ic_launcher" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
res / drawable / border.xml中的
<?xml version="1.0" encoding="utf-8"?><!-- res/drawable/rounded_edittext.xml -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle">
<stroke
android:width="3dp"
android:color="#000000" />
<corners android:radius="0dp" />
</shape>
<强>输出强>
答案 1 :(得分:0)
使父级的相对布局。
<RelativeLayout android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation=horizontal"
android:alignParentTop=""
android:id="llTopH".....>
<your code for top layout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation=horizontal"
android:layout_below="llTopH"
android:weightSum = "2"
android:id="llTopH2".....>
<LineraLayout
android:layout_width="0dp"
android:weight = "1"
android:layout_height="wrap_content"
/>
<LineraLayout
android:layout_width="0dp"
android:weight = "1"
android:layout_height="wrap_content"
/>
this will two layouts on 2nd line
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation=horizontal"
android:layout_below="llTopH2"
android:weightSum = "2"
android:id="llTopH3".....>
<LineraLayout
android:layout_width="0dp"
android:weight = "1"
android:layout_height="wrap_content"
/>
<LineraLayout
android:layout_width="0dp"
android:weight = "1"
android:layout_height="wrap_content"
/>
this will two layouts on 3rd line
</LinearLayout>
</RelativeLayout>
答案 2 :(得分:0)
<?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="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<ListView
android:id="@+id/listview"
android:rotation="-90"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:orientation="horizontal"
android:weightSum="2">
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@mipmap/ic_launcher" />
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@mipmap/ic_launcher" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:orientation="horizontal"
android:weightSum="2">
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@mipmap/ic_launcher" />
<ImageButton
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="@mipmap/ic_launcher" />
</LinearLayout>
</LinearLayout>
<