我想編碼這個對話框佈局:http://fooh.pl/pokaz/348687655.pngandroid如何編寫對話框佈局
綠色的容器是在橙色容器中。在對話框的頂部是TextView。在右上角是一個按鈕。
我知道佈局的類型,但我失敗了。
任何人都可以幫助我嗎?請。
我想編碼這個對話框佈局:http://fooh.pl/pokaz/348687655.pngandroid如何編寫對話框佈局
綠色的容器是在橙色容器中。在對話框的頂部是TextView。在右上角是一個按鈕。
我知道佈局的類型,但我失敗了。
任何人都可以幫助我嗎?請。
在這裏你去:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/rounded_orange">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="8dp"
android:text="Text"/>
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="32dp"
android:background="@drawable/rounded_green">
</RelativeLayout>
</RelativeLayout>
凡可繪製(這裏只顯示綠色)的佈局是這樣的:
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#0F0"/>
<corners android:radius="16dp"/>
</shape>
如果您需要幫助應用定製layout.xml文件在你的對話框中,閱讀Dialog官方文檔中的'創建自定義對話框'。
謝謝! :) 現在,可以爲這些容器設置背景圖像嗎? (.png或.9.png) – user2209414
是的,如果您更喜歡使用xml定義的drawable,則還可以使用9修補程序設置每個RelativeLayout的背景。如果這回答您的問題,請點擊向下箭頭下的複選標記接受我的回答。 – klmprt
那麼如何在這個橙色容器中設置9路徑圖像呢?以及如何在此佈局上設置按鈕? – user2209414
以下是documentation with good examples的鏈接或如何根據佈局創建對話框片段。
和here是一個很好的答案,它顯示瞭如何膨脹佈局以用於對話框片段。
沒有冒犯,但世界上這樣的問題如何得到upvote?請提供您嘗試過的代碼,我們可以幫助您學習。 – codeMagic
我不是在說謊。 這是我的代碼:http://pastebin.com/cbSrk095 它的工作原理,但我不能添加到此佈局關閉按鈕。 – user2209414