What Is The Android Equivalent Of This Xaml Grid?
Solution 1:
Try this:
<?xml version="1.0" encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="wrap_content"><TextViewandroid:text="AppName"android:textAppearance="?android:attr/textAppearanceLarge"android:layout_width="match_parent"android:layout_height="wrap_content"android:id="@+id/textView1"android:gravity="center_horizontal" /><LinearLayoutandroid:id="@+id/bottomLayout"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:orientation="horizontal"><Buttonandroid:text="Button"android:id="@+id/button1"android:layout_width="0dp"android:layout_weight="50"android:layout_height="match_parent" /><Buttonandroid:text="Button"android:layout_width="0dp"android:layout_weight="50"android:layout_height="match_parent"android:id="@+id/button2" /></LinearLayout><ListViewandroid:minHeight="25px"android:layout_width="fill_parent"android:id="@+id/listView1"android:choiceMode="multipleChoice"android:drawSelectorOnTop="true"android:layout_height="fill_parent"android:layout_alignParentRight="false"android:layout_above="@id/bottomLayout"android:layout_below="@id/textView1" /></RelativeLayout>
Edit: The "fill_parent" on listView1 was pushing the layout w/ buttons outside the screen. I moved the layout on top of the ListView and made it to align with the bottom of the parent (otherwise they would show up at top).
android:layout_alignParentBottom="true"
Then made the ListView align on top of the bottomLayout in addition to being at bottom of textView1.
android:layout_above="@id/bottomLayout"
android:layout_below="@id/textView1"
Solution 2:
You should use LinearLayout
.RelativeLayout
are not cross-platform friendly and can't be understood from an XAML or iOS perspective.
Anyway.
XAML Auto
is the equivalent to Android android:wrap_content
To fill the whole LinearLayout with a view, you useandroid:fill_parent
and to just have the view filling the remaining space, you need to combine it withandroid:layout_weight="1"
. That's strange but it works and allow to achieve more complex layouts easily.
<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent"><TextViewandroid:text="Text1"android:layout_height="wrap_content"android:layout_width="fill_parent" /><ListBoxandroid:layout_weight="1"android:layout_height="fill_parent"android:layout_width="fill_parent" /><LinearLayoutandroid:orientation="horizontal"android:layout_height="wrap_content"android:layout_width="fill_parent"><Buttonandroid:layout_height="wrap_content"android:layout_width="wrap_content"android:text="Button 1" /><Buttonandroid:layout_height="wrap_content"android:layout_width="wrap_content"android:text="Button 2" /></LinearLayout></LinearLayout>
Note that LinearLayout
is used both as a way to specify the size behavior - equivalent to rows and columns auto and start - , and as a StackPanel
since it stacks anything based on it's orientation.
Post a Comment for "What Is The Android Equivalent Of This Xaml Grid?"