首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在LinearLayout中将按钮对齐到最右边的角落?

如何在LinearLayout中将按钮对齐到最右边的角落?
EN

Stack Overflow用户
提问于 2013-07-19 15:59:50
回答 5查看 9.2K关注 0票数 1

请看下面的代码

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:background="#373734"
    android:orientation="horizontal" >

        <ImageView
            android:id="@+id/backToLanguageSelectionButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingBottom="5dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="15dp"
            android:paddingTop="5dp"
            android:src="@drawable/thunderbolt" />

        <ImageView
            android:id="@+id/internetButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingBottom="5dp"
            android:paddingTop="5dp"
            android:src="@drawable/globe_small_2" />

        <Button
            android:id="@+id/giveUpButton"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_marginLeft="350dp"
            android:paddingTop="5dp"
            android:paddingBottom="5dp"
            android:text="Button" />



</LinearLayout>

这是一个通用的布局代码,我正在使用所有的android活动。问题出在按钮上,我想让它移到最右边的角落。边距似乎不能正常工作,因为在不同的设备中,按钮位于不同的位置。

如何才能将其移动到最右侧的角落,在所有设备中显示相同的内容?

EN

Stack Overflow用户

回答已采纳

发布于 2013-07-19 16:28:43

我相信您可以在第二个ImageView和您的按钮之间添加一个视图,并将其设置为layout_width="0dp",layout_weight="1“。去掉按钮的左边距。

票数 4
EN
查看全部 5 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17740970

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档