开发者

Problems aligning ImageButton within LinearLayout?

开发者 https://www.devze.com 2023-04-09 02:30 出处:网络
This is my code: <?xml version=\"1.0\" encoding=\"utf-8\"?> <LinearLayout android:id=\"@+id/LinearLayout01\"

This is my code:

    <?xml version="1.0" encoding="utf-8"?>

<LinearLayout android:id="@+id/LinearLayout01"
android:background="@drawable/game_background"
android:weightSum="100"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <ScrollView android:id="@+id/ScrollView01" android:layout_weight="70"
        android:layout_width="fill_parent" android:layout_height="228dp">
        <LinearLayout android:layout_width="wrap_content"
            android:layout_height="30px" android:id="@+id/LinearLayout02"
            android:orientation="vertical">
            <TextView android:layout_height="wrap_content" android:text="Version 0.0.0.1"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:layout_width="wrap_content" android:textColor="#000000"></TextView>


            <TextView
                android:text="Thanks for trying out the very first version of this program!\n\n"
                android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#000000"></TextView>


            <ImageButton android:id="@+id/imageButton1"
                android:layout_height="wrap_content" android:layout_width="wrap_content"
                android:src="@drawable/prefs_exit" android:onClick="exit_button"
                android:background="#00000000"></ImageButton>


        </LinearLayout>
    </ScrollView>


    <LinearLayout android:layout_width="fill_parent" android:layout_weight="30"
            android:layout_height="fill_parent" android:id="@+id/LinearLayout02"
            android:orientation="vertical">
            <ImageButton android:id="@+id/imageButton1"
                android:layout_height="wrap_content" android:layout_width="wrap_content"
                android:src="@drawable/prefs开发者_开发百科_exit" android:onClick="exit_button"
                android:background="#00000000"></ImageButton>


        </LinearLayout>
</LinearLayout>

The problem is the image button in the second linearLayout comes on the right side of the screen instead of at the bottom :(

How do I fix this?

And finally, I want to put a graphic (a logo) on the total bottom, right corner side.

Note, I am a newbie and still very much learning this... just got lost via the examples.

Thanks! Ryan


try adding android:orientation="vertical" to the first LinearLayout

UPDATE

as for logo to the right, try android:gravity="right" in your second LinearLayout


Here is your correct layout, just check it and just replace the background images with your images. Have fun developing applications.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android:id="@+id/LinearLayout01"
    android:background="#ffffff"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:weightSum="100">

    <LinearLayout
        android:layout_height="fill_parent"
        android:id="@+id/linearLayout1"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:gravity="center">

        <ScrollView
            android:id="@+id/ScrollView01"
            android:layout_height="228dp"
            android:layout_width="fill_parent">

            <LinearLayout
                android:layout_width="wrap_content"
                android:id="@+id/LinearLayout02"
                android:layout_height="30px"
                android:orientation="vertical">

                <TextView
                    android:textColor="#000000"
                    android:text="Version 0.0.0.1"
                    android:layout_height="wrap_content"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:layout_width="wrap_content"></TextView>

                <TextView
                    android:textColor="#000000"
                    android:text="Thanks for trying out the very first version of this program!\n\n"
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"></TextView>

                <ImageButton
                    android:src="@drawable/icon"
                    android:layout_height="wrap_content"
                    android:background="#00000000"
                    android:onClick="exit_button"
                    android:id="@+id/imageButton1"
                    android:layout_width="wrap_content"></ImageButton>

                <LinearLayout
                    android:layout_height="fill_parent"
                    android:id="@+id/LinearLayout02"
                    android:layout_weight="30"
                    android:orientation="vertical"
                    android:layout_width="fill_parent">

                    <ImageButton
                        android:src="@drawable/icon"
                        android:layout_height="wrap_content"
                        android:background="#00000000"
                        android:onClick="exit_button"
                        android:id="@+id/imageButton1"
                        android:layout_width="wrap_content"></ImageButton>
                </LinearLayout>
            </LinearLayout>
        </ScrollView>
    </LinearLayout>
</LinearLayout>
0

精彩评论

暂无评论...
验证码 换一张
取 消