簡體   English   中英

Android左下角的轉彎按鈕

[英]Cornering button to bottom left android

我正在嘗試做一個與CandyCrush完全相同的菜單:中間有兩個按鈕(播放和連接),然后在左下角右移,還有另一個按鈕(CC的箭頭)。 我設法將第一個放置在按鈕上,但是無法將最后一個放置在活動的左下角。 我該如何定位? 這是我的xml,並且我使用相對布局。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<ImageView
    android:id="@+id/balao"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:adjustViewBounds="true"  
    android:scaleType="fitCenter"  
    android:background="@null"
    android:maxWidth="200dp"  
    android:maxHeight="180dp"
    android:layout_weight="1"
    android:layout_marginTop="10dp"
    android:layout_marginBottom="35dp"
    android:src="@drawable/balao" />
<ImageButton
    android:id="@+id/play"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:layout_centerHorizontal="true"
    android:maxWidth="80dp"  
    android:maxHeight="80dp"
    android:background="@android:color/transparent"   
    android:layout_below="@+id/balao"
    android:layout_weight="1"
    android:layout_marginBottom="10dp"
    android:src="@drawable/playbutton" />
<ImageButton
    android:id="@+id/tutor"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:layout_below="@+id/play"  
    android:layout_centerHorizontal="true"
    android:maxWidth="50dp"  
    android:maxHeight="50dp"
    android:background="@android:color/transparent"   
    android:layout_weight="1"
    android:src="@drawable/tutor" />

<ImageButton
        android:id="@+id/corner"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:adjustViewBounds="true"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:src="@drawable/corner"/>
</RelativeLayout>

對於最后一個按鈕,請使用android:layout_width="wrap_content"代替android:layout_width="fill_parent"

即:

<ImageButton
    android:id="@+id/corner"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:adjustViewBounds="true"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:src="@drawable/corner"/>

重量屬性不適用於RelativeLayout,因此請從xml中刪除:

android:layout_weight="1" // remove this properties

將底部按鈕設置為左側,簡單地將寬度設置為wrap而不是fill:

 android:layout_width="wrap_content"

暫無
暫無

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

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