rules for android UI
I 'm having problems with my android UI. My buttons dont align properly. Even though i have my button aligned to right, but still wont line up correctly?
I was wondering is there any document that would explain how to layout things correctly and how would widgets behave when they are inside a tablerow? Or in other terms how does hierarchy affect the way things are aligned?? Thanks
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
style="?screenBackground">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<TableLayout android:id="@+id/TableLayout02"
android:layout_width="match_parent" android:layout_height="match_parent"
style="?pageBackground">
<TableRow>
<ImageView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:src="@drawable/camera_icon"
android:id="@+id/img" android:layout_grav开发者_如何学Pythonity="left"></ImageView>
<Button android:id="@+id/button1" android:text="@string/button1"
style="?button"></Button>
</TableRow>
</TableLayout>
</LinearLayout>
</ScrollView>
You might have better luck using a RelativeLayout
instead of LinearLayout
.
For example, you could align your ImageView
and Button
like this:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_height="60dip"
android:layout_width="60dip"
android:layout_alignParentLeft="true"/>
<Button
android:text="Button"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
To get a feel for what is possible, the starter docs on RelativeLayout
are here and here.
精彩评论