在 LinearLayout 中对齐 ImageButton 时出现问题?

发布于 2024-12-07 01:34:07 字数 2304 浏览 0 评论 0原文

这是我的代码:

    <?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>

问题是第二个 LinearLayout 中的图像按钮位于屏幕的右侧而不是底部:(

我该如何解决这个问题?

最后,我想在上面放置一个图形(徽标)总底部,右角

注意,我是一个新手,仍然在学习这个......只是通过示例迷失了

谢谢! 瑞安

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

木落 2024-12-14 01:34:08

尝试将 android:orientation="vertical" 添加到第一个 LinearLayout

UPDATE

至于右侧的徽标,尝试 android:gravity=第二个 LinearLayout 中的“right”

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

UPDATE

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

橪书 2024-12-14 01:34:08

这是正确的布局,只需检查它并用您的图像替换背景图像即可。享受开发应用程序的乐趣。

<?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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文