简体   繁体   English

Android版式图片右上角

[英]Android Layout Image Top Right Corner

I am showing texts and images in a certain format and it looks like this now 我正在以某种格式显示文本和图像,现在看起来像这样

在此处输入图片说明

Now I am trying to add another image top right that is horizontal to the header text so like this 现在,我尝试在右上角添加另一个与标题文本水平的图像,如下所示

在此处输入图片说明

I just can't seem to get that image in the right corner vertical to header without messing up that other text and images 我只是似乎无法在不弄乱其他文本和图像的情况下使图像垂直于标题垂直

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:orientation="vertical"
>

<TextView

    android:id="@+id/header"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="text"
    android:textColor="#FFFFFF"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:paddingBottom="5dp"
    android:paddingTop="5dp"
    android:textSize="30sp"
    android:textStyle="bold"
    />

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageFavourites"
    android:layout_gravity="right" />

<LinearLayout

    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:background="#C3C3C3"
    android:orientation="horizontal">

    <ImageView

        android:id="@+id/imageView1"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="5dp"
        android:layout_marginEnd="4dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="4dp"
        android:layout_marginStart="10dp"
        android:layout_marginTop="5dp"
        android:adjustViewBounds="true"
        android:scaleType="fitXY"
        android:src="@drawable/ic_launcher"/>

    <TextView

        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:text="text"
        android:layout_marginEnd="4dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="4dp"
        android:layout_marginStart="10dp"
        android:layout_marginTop="5dp"
        android:textColor="@color/colorWhite"
        android:textSize="18sp" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="4dp"
        android:layout_marginRight="4dp"
        android:layout_marginStart="4dp"
        android:layout_marginTop="5dp"
        android:adjustViewBounds="true"
        android:gravity="center"
        android:scaleType="fitXY"
        android:src="@drawable/ic_launcher"/>

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="text"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="4dp"
        android:layout_marginRight="4dp"
        android:layout_marginStart="4dp"
        android:layout_marginTop="5dp"
        android:textColor="@color/colorWhite"
        android:textSize="18sp" />

    <ImageView
        android:id="@+id/imageView3"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="4dp"
        android:layout_marginRight="4dp"
        android:layout_marginStart="4dp"
        android:layout_marginTop="5dp"
        android:src="@drawable/ic_launcher"/>

    <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="text"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="4dp"
        android:layout_marginRight="4dp"
        android:layout_marginStart="4dp"
        android:layout_marginTop="5dp"
        android:textColor="@color/colorWhite"
        android:textSize="18sp" />



</LinearLayout>


</LinearLayout>
<LinearLayout

    android:background="#000000"
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:orientation="vertical">

    <RelativeLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent">
        <TextView

            android:id="@+id/header"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:paddingBottom="5dp"
            android:paddingLeft="5dp"
            android:paddingRight="5dp"
            android:paddingTop="5dp"
            android:text="text"
            android:textColor="#FFFFFF"
            android:textSize="30sp"
            android:textStyle="bold" />

        <ImageView
            android:id="@+id/imageFavourites"
            android:layout_alignParentRight="true"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content" />

    </RelativeLayout>

    <LinearLayout

        android:background="#C3C3C3"
        android:layout_gravity="center_horizontal"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:orientation="horizontal">

        <ImageView

            android:adjustViewBounds="true"
            android:id="@+id/imageView1"
            android:layout_gravity="center_horizontal"
            android:layout_height="40dp"
            android:layout_marginBottom="5dp"
            android:layout_marginEnd="4dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="4dp"
            android:layout_marginStart="10dp"
            android:layout_marginTop="5dp"
            android:layout_width="40dp"
            android:scaleType="fitXY"
            android:src="@drawable/ic_launcher" />

        <TextView

            android:id="@+id/textView2"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginEnd="4dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="4dp"
            android:layout_marginStart="10dp"
            android:layout_marginTop="5dp"
            android:layout_width="wrap_content"
            android:text="text"
            android:textColor="@color/colorWhite"
            android:textSize="18sp" />

        <ImageView
            android:adjustViewBounds="true"
            android:gravity="center"
            android:id="@+id/imageView2"
            android:layout_gravity="center_horizontal"
            android:layout_height="40dp"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="4dp"
            android:layout_marginRight="4dp"
            android:layout_marginStart="4dp"
            android:layout_marginTop="5dp"
            android:layout_width="40dp"
            android:scaleType="fitXY"
            android:src="@drawable/ic_launcher" />

        <TextView
            android:id="@+id/textView3"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="4dp"
            android:layout_marginRight="4dp"
            android:layout_marginStart="4dp"
            android:layout_marginTop="5dp"
            android:layout_width="wrap_content"
            android:text="text"
            android:textColor="@color/colorWhite"
            android:textSize="18sp" />

        <ImageView
            android:id="@+id/imageView3"
            android:layout_gravity="center_horizontal"
            android:layout_height="40dp"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="4dp"
            android:layout_marginRight="4dp"
            android:layout_marginStart="4dp"
            android:layout_marginTop="5dp"
            android:layout_width="40dp"
            android:src="@drawable/ic_launcher" />

        <TextView
            android:id="@+id/textView4"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="4dp"
            android:layout_marginRight="4dp"
            android:layout_marginStart="4dp"
            android:layout_marginTop="5dp"
            android:layout_width="wrap_content"
            android:text="text"
            android:textColor="@color/colorWhite"
            android:textSize="18sp" />


    </LinearLayout>


</LinearLayout>

将这三个图像保留在LinearLayout并创建一个RelativeLayout作为LinearLayoutimageFavouritesimageFavourites

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM