簡體   English   中英

相對布局,包含FrameLayout和其他一些組件

[英]Relative Layout containing FrameLayout and few other components

首先,請原諒我對此主題的糟糕命名。

我有以下布局設置:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".PersonDetails" >
    <FrameLayout
        android:id="@+id/bannerLayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <ImageView
            android:id="@+id/coverImage"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:scaleType="fitStart"
            android:src="@drawable/default_cover">
        </ImageView>

        <ImageView
            android:id="@+id/thumbImage"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="left|bottom"
            android:scaleType="fitStart"
            android:src="@drawable/fingerprint_ic" />
    </FrameLayout>
    <TextView
        android:id="@+id/textName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Large Text"
        android:textColor="#55FF55"
        android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>

我想要達到的目的是要有一面橫幅(很像橫跨屏幕頂部的Facebook封面)。 在橫幅的左上角有一張縮略圖。

標語的高度應僅占屏幕高度的1/4。 由於我將需要其余空間用於其他組件。

在橫幅的正下方,我想有一個TextView(在左側)和一個按鈕在右側。

到目前為止,我只能將縮略圖放在橫幅的頂部,但是我不知道如何將其放在橫幅的左下角(我可以使用marginTop進行設置,但是,我認為這不是正確的方法)。

有誰知道如何實現這一目標? 謝謝。

編輯#1:

這是UI

自定義布局

根據您的描述,我認為您想做這樣的事情:

我使用了2個布局作為內容的linearlayout。 使用android:layout_weight屬性,我們可以使頂部布局占用空間的1/4,而底部布局則可以使用其余空間。

然后將圖標放置在頂部布局中,我們使用alignParentBottom使其粘在底部。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PersonDetails"
android:orientation="vertical">


<RelativeLayout
    android:id="@+id/bannerLayout"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1">

    <ImageView
        android:id="@+id/coverImage"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:scaleType="fitXY"
        android:src="@drawable/default_cover"></ImageView>

    <ImageView
        android:id="@+id/thumbImage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:scaleType="fitStart"
        android:src="@drawable/fingerprint_ic" />
</RelativeLayout>



<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_weight="3"
    android:layout_margin="10dp">

    <TextView
        android:id="@+id/textName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="40dp"
        android:text="Large Text"
        android:textColor="#55FF55"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Button"
        android:id="@+id/button"
        android:layout_alignParentEnd="true"/>

</RelativeLayout>

</LinearLayout>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM