In meinem benutzerdefinierten Dialogfeld versuche ich, meine Checkbox unter meinem scrollview zu bleiben, aber es funktioniert nicht. Ich habe versucht, das Kontrollkästchen unter der Scrollview in Xml, aber es erscheint nicht, wenn ich die App ausführen. Was muss getan werden, damit das Kontrollkästchen am unteren Rand des Dialogfelds (unterhalb der Bildlaufansicht) bleibt und nicht Teil der Bildlaufansicht ist, wenn ich es blättern lasse? Ich möchte nicht, dass meine Checkbox mit dem Scrollview blättert.CheckBox bleibt nicht am unteren Ende des Dialogs
java
LayoutInflater inflater = LayoutInflater.from(this);
View dialog_layout = inflater.inflate(R.layout.fragment_overlay, (ViewGroup) findViewById(R.id.Overlay_linearLayout));
AlertDialog.Builder db = new AlertDialog.Builder(this);
db.setView(dialog_layout);
db.setPositiveButton("OK", new DialogInterface.OnClickListener() {
});
db.show();
xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/Overlay_linearLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/Overlay_scrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/Overlay_tableLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="1.0">
<TableRow
android:padding="10dp">
<ImageView
android:layout_width="0px"
android:layout_weight="0.3"
android:layout_height="80dp"
android:src="@drawable/img_0" />
<TextView
android:id="@+id/MapOverlay_textView0"
android:layout_width="0px"
android:layout_weight="0.7"
android:text="@string/overlay_instruction0" />
</TableRow>
<TableRow
android:padding="10dp">
<ImageView
android:layout_width="0px"
android:layout_weight="0.3"
android:layout_height="80dp"
android:src="@drawable/img_1" />
<TextView
android:id="@+id/MapOverlay_textView1"
android:layout_width="0px"
android:layout_weight="0.7"
android:text="@string/overlay_instruction1" />
</TableRow>
<TableRow
android:padding="10dp">
<ImageView
android:layout_width="0px"
android:layout_weight="0.3"
android:layout_height="80dp"
android:src="@drawable/img_2" />
<TextView
android:id="@+id/MapOverlay_textView2"
android:layout_width="0px"
android:layout_weight="0.7"
android:text="@string/overlay_instruction2" />
</TableRow>
<TableRow
android:padding="10dp">
<ImageView
android:layout_width="0px"
android:layout_weight="0.3"
android:layout_height="80dp"
android:src="@drawable/img_3" />
<TextView
android:id="@+id/MapOverlay_textView3"
android:layout_width="0px"
android:layout_weight="0.7"
android:text="@string/overlay_instruction3"
style="@android:style/TextAppearance.Medium" />
</TableRow>
<TableRow>
<CheckBox
android:text="Don't show this again"
android:id="@+id/skip"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
</ScrollView>
ziehen 'CheckBox' aus dem' ScrollView', und sie beide in einer anderen 'ViewGroup' setzen; z. B. ein vertikal ausgerichteter LinearLayout. –
halten Sie 'checkbox' außerhalb' 'ScrollView' 'und wickeln Sie' ScrollView' und 'CheckBox' in' LinearLayout' ein. –
okey Sie können auch 'RelativeLayout' verwenden und' android: alignParentBottom = "true" 'zum Kontrollkästchen hinzufügen. BEARBEITEN: Sie können den zweiten Parameter durch null ersetzen 'View dialog_layout = inflater.inflate (R.layout.fragment_overlay, null);' –