android - 将ImageView与布局android的右侧对齐

标签 android android-layout

我有一个布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FFFFFF">

    <TextView android:id="@+id/groupname"
         android:paddingLeft="50px"
         android:textSize="16px"
         android:background="#FFFFFF"
         android:textColor="#000000"
         android:textStyle="normal"
         android:layout_width="wrap_content"
         android:layout_height="50px"/>
     <ImageView
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_gravity="right"
             android:layout_marginRight="6dp"
             android:background="#ffffff" 
             android:src="@drawable/sort"/>

</LinearLayout>

Rendering like this presently I want to render like this

现在正在像在第一张图像中一样进行渲染,但我想像在第二张图像中那样完全右对齐。任何帮助都会很有用。

期待您的回复。 谢谢。

最佳答案

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FFFFFF">

    <TextView android:id="@+id/groupname"
         android:paddingLeft="50dp"
         android:textSize="16dp"
         android:textColor="#000000"
         android:textStyle="normal"
         android:layout_width="fill_parent"
         android:layout_height="50dp"
         android:layout_weight="0.9"
         android:background="@color/black"/>
     <ImageView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_gravity="right"
             android:background="#ffffff" 
             android:src="@drawable/checkin"
             android:layout_weight="0.1"/>

</LinearLayout>

Try this, hope this will help.

Prview1 enter image description here

关于android - 将ImageView与布局android的右侧对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9373841/

相关文章:

android - 无法从基本应用和应用崩溃启动动态模块启动 Activity

android - 如何在 xml 中重用不同颜色的已定义可绘制对象

android - 工具栏不会隐藏在 DrawerLayout 中的滚动回收 View 中

android - 如何在 Android 中将按钮置于屏幕中央

android - 通过 sherlock 使用文本颜色作为选项卡指示器 - 如何?

java - 如何实现每月最后一天重复闹钟

android - 为什么从 fragment 触发导航?

java - 如何从 Appium JUnit 测试监控 iOS 模拟器/Android 模拟器的 HTTP 流量?

android - 从暂停恢复时全屏 TabActivity 出现问题

android - 如何更改弹出菜单弹出的位置