我一直在努力让这个工作,我认为我可以使用 RelativeLayout
android:layout_weight="0.3"
Run Code Online (Sandbox Code Playgroud)
在屏幕右侧放置三个按钮,不是居中,而是从顶部向下30%.
这是可能的,如果是这样,我该怎么做?
以下是我的XML,它显示了三个按钮在彼此之下,但在右上角位置:
</RelativeLayout>
<LinearLayout
android:id="@+id/rightRelativeLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_weight="1"
android:orientation="vertical"
>
<ImageButton
android:id="@+id/btn_A"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="A"
android:src="@drawable/drawer_1"
android:background="@android:color/transparent"
/>
<ImageButton
android:id="@+id/btn_B"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:text="B"
android:src="@drawable/drawer_1"
android:background="@android:color/transparent"
android:layout_below="@+id/btn_A"
/>
<ImageButton
android:id="@+id/btn_C"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginTop="10dp"
android:text="C"
android:src="@drawable/drawer_1"
android:background="@android:color/transparent"
android:layout_below="@+id/btn_B"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
[更新]为需要它的人添加了最终工作版本
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical">
<Gallery xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/examplegallery"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<RelativeLayout
android:id="@+id/InnerRelativeLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" >
<Button
android:id="@+id/btn_newpen_drawtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pen"
/>
<EditText
android:id="@+id/etx_addtext_drawtext"
android:layout_width="fill_parent"
android:layout_toLeftOf="@+id/btn_delete_pen"
android:layout_toRightOf="@+id/btn_newpen_drawtext" …Run Code Online (Sandbox Code Playgroud)