簡體   English   中英

Android ListView toRightOf ImageView具有不同的大小而無需調整圖像大小

[英]Android ListView toRightOf ImageView with different size without resizing image

我想有一個Imageview(大小為50dp / 50 dp),在這個圖像的右邊,我想有一個ListView(具有可變大小,取決於我的數據庫,但這不是重點)。 圖像應保持其大小,而列表應具有自己的大小。

我的問題是:我的ListView在左側獲取了我的Imageview的高度。 我希望我的列表可見,沒有任何滾動。 所有這些代碼都放在RelativeLayout中。

<LinearLayout
        android:id="@+id/listAddresses"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:layout_below="@id/AnotherImageWithListOnItsRight" >
        <RelativeLayout
            android:id="@+id/iconAddress"
            android:layout_width="50dp"
            android:layout_height="fill_parent" >
            <ImageView
                android:layout_height="50dp"
                android:layout_width="50dp"
                android:src="@drawable/orange_message" android:scaleType="fitXY"
                />
        </RelativeLayout>
        <ListView 
            android:layout_toRightOf="@id/iconAddress"
            android:id="@+id/listAddressTrue" 
            android:layout_height="fill_parent"
            android:layout_width="fill_parent"
            android:divider="#FFCC00"
            android:dividerHeight="4px" >      
        </ListView>
</LinearLayout>

我還設法讓我的完整ListView沒有滾動,但如果我這樣做,我的圖像的高度是可怕的......所以我想我可以制作一個RelativeLayout,專用於我的圖像,所以我的圖像不會調整大小,但它不起作用。

有人可以幫我嗎?

PS:對不起我的英文..

這里:

<ListView 
        android:layout_toRightOf="@id/iconAddress"

您正在嘗試使用layout_toRightOf屬性,但這只適用於您在RelativeLayout內部,但您的ListView在LinearLayout內部

因此,將LinearLayout更改為RelativeLayout可能對您有用,因為您可以實際使用此屬性

試試這個..

<LinearLayout
        android:id="@+id/listAddresses"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:layout_below="@id/AnotherImageWithListOnItsRight" >
            <ImageView
                android:layout_height="50dp"
                android:layout_width="50dp"
                android:src="@drawable/orange_message" android:scaleType="fitXY"
                />
        <ListView 
            android:id="@+id/listAddressTrue" 
            android:layout_height="fill_parent"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:divider="#FFCC00"
            android:dividerHeight="4px" >      
        </ListView>
</LinearLayout>

暫無
暫無

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

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