[英]ImageView out of layout bounds
我有一個相對布局的imageview。 您可以在屏幕截圖中看到: 我如何在右下角移動imageview(weel),但僅顯示其中的25%,如下圖所示:
提前致謝 !
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:background="#E0E0E0"
>
<com.androidsources.welcomescreen.MyRecyclerView
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
android:id="@+id/cardList"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<com.anupcowkur.wheelmenu.WheelMenu
android:id="@+id/wheelMenu"
android:layout_width="300dp"
android:layout_height="300dp"
android:src="@drawable/wheel"/>
</RelativeLayout>
您可以嘗試如下操作:
<com.anupcowkur.wheelmenu.WheelMenu
android:id="@+id/wheelMenu"
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:paddingLeft="150dp"
android:paddingTop="150dp"
android:src="@drawable/wheel"/>
alignParentRight
和alignParentBottom
屬性將使窗口小部件移動到右下角。 另外,請嘗試更改padding
以達到所需的視覺效果。
我知道已經有答案了,但是對於那些無法使公認的答案起作用的人,這里是另一種選擇。
出於某種原因,如果我使用RelativeLayout
,則無法將視圖的一部分放置在父級之外,但是當我嘗試使用LinearLayout
它可以工作。 因此,我使用的解決方案是將視圖封裝在LinearLayout
然后將LinearLayout
放置在父對象的底端。
<LinearLayout
android:layout_width="300dp"
android:layout_height="300dp"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true">
<ImageView
android:layout_width="300dp"
android:layout_height="300dp"
android:src="@drawable/some_pic"
android:layout_marginStart="150dp"
android:layout_marginTop="150dp"/>
</LinearLayout>
請注意,圖像的寬度和高度不是match_parent
,使用match_parent
會縮小圖像而不移位它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.