2016-03-25 24 views
-1

カスタムダイアログで、自分のスクロールバーの下にチェックボックスを置こうとしていますが、動作していません。私はxmlのscrollviewの下にチェックボックスを追加しようとしましたが、アプリを実行するたびに表示されません。チェックボックスをダイアログの下部(スクロールビューの下)のままにして、スクロールするときにスクロールビューの一部にならないようにするためには、何をする必要がありますか?私は自分のチェックボックスをスクロールビューでスクロールさせたくありません。ダイアログボックスの下部にCheckBoxが表示されない

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> 

+0

'ScrollView'のうち' checkbox'でを引き、別の 'ViewGroup'の内側の両方に置きます。例えば、垂直方向の「LinearLayout」である。 –

+0

'ScrollView'の外側に' checkbox'を置いて、 'LinearLayout'に' ScrollView'と 'CheckBox'をラップしてください。 –

+0

okeyでは' RelativeLayout'を使用し、 'android:alignParentBottom =" true "'をチェックボックスに追加することもできます。編集:あなたは2番目のパラメータをnullに置き換えることができます 'View dialog_layout = inflater.inflate(R.layout.fragment_overlay、null); –

答えて

1

新しいLinearLayoutの内側checkboxScrolViewを設定しようと、このようScrollViewcheckboxを置きます:

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

    <ScrollView android:id="@+id/Overlay_scrollView" 
       xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="fill_parent" 
       android:layout_height="0dp" 
       android:layout_weight="1"> 

     <TableLayout android:id="@+id/Overlay_tableLayout" 
        xmlns:android="http://schemas.android.com/apk/res/android" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:weightSum="1.0"> 

       <ImageView 
        android:layout_width="0px" 
        android:layout_height="80dp" 
        android:layout_weight="0.3" 
        android:src="@drawable/ic_launcher"/> 

       <TextView 
        android:id="@+id/MapOverlay_textView0" 
        android:layout_width="0px" 
        android:layout_weight="0.7" 
        android:text="tion0"/> 


       <ImageView 
        android:layout_width="0px" 
        android:layout_height="80dp" 
        android:layout_weight="0.3" 
        android:src="@drawable/ic_launcher"/> 

       <TextView 
        android:id="@+id/MapOverlay_textView1" 
        android:layout_width="0px" 
        android:layout_weight="0.7" 
        android:text="dada"/> 


       <ImageView 
        android:layout_width="0px" 
        android:layout_height="80dp" 
        android:layout_weight="0.3" 
        android:src="@drawable/ic_launcher"/> 

       <TextView 
        android:id="@+id/MapOverlay_textView2" 
        android:layout_width="0px" 
        android:layout_weight="0.7" 
        android:text="ruction2"/> 


       <ImageView 
        android:layout_width="0px" 
        android:layout_height="80dp" 
        android:layout_weight="0.3" 
        android:src="@drawable/ic_launcher"/> 

       <TextView 
        android:id="@+id/MapOverlay_textView3" 
        style="@android:style/TextAppearance.Medium" 
        android:layout_width="0px" 
        android:layout_weight="0.7" 
        android:text="_instruction3"/> 


     </TableLayout> 
    </ScrollView> 

    <CheckBox 
     android:id="@+id/skip" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Don't show this again"/> 
</LinearLayout> 

UPDATE

どうxmlファイルを膨張させると、あなたのレイアウトファイルにこれを試してみてくださいdialog

LayoutInflater inflater = getLayoutInflater(); 
View dialoglayout = inflater.inflate(R.layout.dialog_layout, null); 
AlertDialog.Builder builder = new AlertDialog.Builder(this); 
builder.setView(dialoglayout); 
builder.show(); 
+0

このコード行はどうですか? 'view dialog_layout = inflater.inflate(R.layout.fragment_overlay、(ViewGroup)findViewById(R.id.Overlay_linearLayout));' – MacaronLover

+0

チェックボックスが表示されません – MacaronLover

+0

私のシミュレーションでは、このコードhttp:// s27で表示されます。 postimg.org/539925183/Screenshot_8.png、そしてinflaterについてなぜxmlレイアウト全体を膨らませなかったのですか –

0

に設定します。これはいくつかの変更を加えたXMLファイルです。

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

<ScrollView 
    android:id="@+id/Overlay_scrollView" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/skip"> 

    <TableLayout 
     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_height="80dp" 
       android:layout_weight="0.3" 
       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_height="80dp" 
       android:layout_weight="0.3" 
       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_height="80dp" 
       android:layout_weight="0.3" 
       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_height="80dp" 
       android:layout_weight="0.3" 
       android:src="@drawable/img_3" /> 

      <TextView 
       android:id="@+id/MapOverlay_textView3" 
       style="@android:style/TextAppearance.Medium" 
       android:layout_width="0px" 
       android:layout_weight="0.7" 
       android:text="@string/overlay_instruction3" /> 
     </TableRow> 

    </TableLayout> 
</ScrollView> 

<CheckBox 
    android:id="@+id/skip" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:text="Don't show this again" /> 

関連する問題