第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

關于按鈕和圖片的位置

我想知道怎么讓按鈕在圖片的上層。就像PS的圖層那樣,最下層是一整張圖片,然后上面有一個按鈕?;蛘哒f是讓不同的部件不在一個面上。我想知道這個可以實現(xiàn)么?注意:一定是通過添加ImageView添加的圖片而不是給XML文件設置背景。感激大佬前來解答,如果還不明白的可以問我,隨時解釋!



獻上來自萌新的敬意^_^

正在回答

3 回答

不是,我不懂 Include :(

我用相對定位,button相對于imageView相對定位,比較簡單。

<?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"?>

????<ImageView
????????android:id="@+id/imageView1"
????????android:layout_width="200dp"
????????android:layout_height="200dp"
????????android:layout_alignParentLeft="true"
????????android:layout_alignParentTop="true"
????????android:layout_marginLeft="28dp"
????????android:layout_marginTop="73dp"
????????android:src="@android:drawable/btn_default_small"?/>

????<Button
????????android:id="@+id/button1"
????????android:layout_width="wrap_content"
????????android:layout_height="wrap_content"
????????android:layout_alignLeft="@+id/imageView1"
????????android:layout_alignTop="@+id/imageView1"
????????android:layout_marginLeft="58dp"
????????android:layout_marginTop="70dp"
????????android:text="Button"?/>

</RelativeLayout>

這樣..


0 回復 有任何疑惑可以回復我~
#1

deemos 提問者

沒法再回復里加代碼,就自己回答了一下,可以看下。
2017-07-24 回復 有任何疑惑可以回復我~
<?xml?version="1.0"?encoding="utf-8"?>
<RelativeLayout?xmlns:android="http://schemas.android.com/apk/res/android"
????xmlns:app="http://schemas.android.com/apk/res-auto"
????android:layout_width="match_parent"
????android:layout_height="match_parent"
????android:orientation="vertical">


????<ImageView
????????android:id="@+id/imageView1"
????????android:layout_width="match_parent"
????????android:layout_height="match_parent"
????????android:background="@drawable/g04"
????????android:layout_alignParentTop="true"
????????android:layout_alignParentStart="true"?/>

????<include
????????android:layout_width="wrap_content"
????????android:layout_height="wrap_content"
????????layout="@layout/layout01"
????????android:layout_centerVertical="true"
????????android:layout_centerHorizontal="true"?/>

</RelativeLayout>

上面是主要布局XML

<?xml?version="1.0"?encoding="utf-8"?>
<LinearLayout?xmlns:android="http://schemas.android.com/apk/res/android"
????android:layout_width="match_parent"
????android:layout_height="match_parent"
????android:gravity="center_horizontal"
????android:orientation="vertical">

????<ToggleButton
????????android:id="@+id/toggleButton"
????????android:checked="true"
????????android:textOn="@string/blu"
????????android:textOff="@string/bac"
????????android:layout_width="wrap_content"
????????android:layout_height="wrap_content"
????????android:background="#9a000000"/>
</LinearLayout>

這是次要布局XML

我是這樣寫的,也可以實現(xiàn)

0 回復 有任何疑惑可以回復我~
#1

慕田峪630870

謝謝? 不過我還沒學到include,等學到了在仔細看看,祝你學習進步?
2017-07-24 回復 有任何疑惑可以回復我~
#2

deemos 提問者 回復 慕田峪630870

謝啦,感覺include用起來更靈活一些
2017-07-24 回復 有任何疑惑可以回復我~

http://img1.sycdn.imooc.com//5971a08c0001fd0d02680314.jpg

是這樣嗎?

用?RelativeLayout 布局,很簡單的

0 回復 有任何疑惑可以回復我~
#1

deemos 提問者

我剛剛研究出來了,使用Include寫的,對吧?
2017-07-21 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
Android攻城獅的第一門課(入門篇)
  • 參與學習       312507    人
  • 解答問題       4931    個

想快速掌握Android應用開發(fā)基礎,選擇學習這門課程就對了。

進入課程

關于按鈕和圖片的位置

我要回答 關注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號