Dah lama saya telah menyelidik bagi layout seperti ini untuk menambahbaik projek m-mathurat . Saya perlu reka bentuk susun atur yang mempunyai WebView di atas beberapa butang kawalan. Jumpa sampel dalam StackOverFlow di mana ia adalah contoh terbaik yang boleh digunakan. Kredit kepada jkhouw1.
- Dengan menggunakan RelativeLayout, View boleh disusun secara relatif dengan View yang lain.
- Saya menetapkan LinearLayout untuk butang kawalan dan setkan id = buttonlayout
- WebView perlu disetkan ini android: layout_above = “@ id / buttonlayout”
Kod XML dalam main.xml;
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:background="@drawable/islamicbg"
android:layout_height="fill_parent">
<!—perhatikan id=buttonlayout -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_alignParentBottom="true"
android:id="@+id/buttonlayout">
<!-- perhatikan android:layout_weight="1.0" -->
<ImageButton android:id="@+id/btnprev"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_weight="1.0" android:layout_alignParentBottom="true"
android:src="@drawable/prevpage"/>
<ImageButton android:id="@+id/btnplay"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_weight="1.0" android:layout_alignParentBottom="true"
android:src="@drawable/play" android:layout_toRightOf="@+id/btnprev"
/>
<ImageButton android:id="@+id/btnpause"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_alignParentBottom="true" android:layout_weight="1.0"
android:src="@drawable/pause" android:layout_toRightOf="@+id/btnplay"
/>
<ImageButton android:id="@+id/btnstop"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_weight="1.0" android:layout_alignParentBottom="true"
android:src="@drawable/stop" android:layout_toRightOf="@+id/btnpause"
/>
<ImageButton android:id="@+id/btnnext"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_weight="1.0" android:layout_alignParentBottom="true"
android:src="@drawable/nextpage" android:layout_toRightOf="@+id/btnstop"
/>
</LinearLayout>
<!-- perhatikan android:layout_above="@id/buttonlayout" -->
<WebView android:layout_width="fill_parent" android:id="@+id/webview"
android:layout_above="@id/buttonlayout"
android:layout_height="fill_parent" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/title"
android:background="#ffffff">
<TextView android:text="m-Mathurat" android:id="@+id/lbltitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1.0"
/>
</LinearLayout>
</RelativeLayout>
Dapatkan kod lengkap di sini;
You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.
