0

ラジオボタンのLayout_heightを0dpに設定しました。ボタンを押したときにコンテンツをラップするようにプログラムで変更したいと考えています。レイアウトの変更_ラジオボタンのコードの高さ

r1 = (RadioButton) d.findViewById(R.id.textView5); 
       r2 = (RadioButton) d.findViewById(R.id.textView6); 
       r3 = (RadioButton) d.findViewById(R.id.textView15); 

       //set up button 
       Button button = (Button) d.findViewById(R.id.button2); 
       button.setOnClickListener(new View.OnClickListener() { 
        @Override 
        public void onClick(View v) { 
         finish(); 
        } 
       }); 
       Button button2 = (Button) d.findViewById(R.id.button8); 
       button2.setOnClickListener(new View.OnClickListener() { 
        @Override 
        public void onClick(View v) { 


         r1.setLayoutParams(new FrameLayout.LayoutParams(AbsListView.LayoutParams.WRAP_CONTENT, 20)); 
         // Tried this but it's not working 


        } 
       }); 

は、ここに私のXMLコード

<LinearLayout 
android:orientation="vertical" android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:minWidth="500dp"> 


    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Select Industry" 
     android:id="@+id/button8" 
     android:layout_alignParentTop="true" 
     android:layout_alignLeft="@+id/button11" 
     android:layout_alignStart="@+id/button11" 
     android:layout_marginTop="38dp" 
     android:layout_gravity="center_horizontal" /> 

<RadioButton 
    android:layout_width="wrap_content" 
    android:layout_height="0dp" 
    android:id="@+id/textView5" 
    android:layout_gravity="center_horizontal" 
    android:text="Entertainment" /> 

<RadioButton 
    android:layout_width="wrap_content" 
    android:layout_height="0dp" 
    android:text="Garments" 
    android:id="@+id/textView6" 
    android:layout_gravity="center_horizontal" /> 

<RadioButton 
    android:layout_width="wrap_content" 
    android:layout_height="0dp" 
    android:text="Information Technology" 
    android:id="@+id/textView15" 
    android:layout_gravity="center_horizontal" /> 

それは働いていない理由を私は知らない、事前に感謝です!

+0

あなたのXMLコードを投稿 – kgandroid

+0

@kgandroid完了、再確認してください。 –

+0

LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT、20)でsetLayoutParamsを試しましたか? – maphongba008

答えて

0

ラジオボタンは組み込みのコントロールであり、固定されているため、実際にはラジオボタンの高さと幅を変更することはできません。

変更する場合は、ラジオボタンの独自のスタイルを定義する必要があります。hereを探してください。

+0

いいえ、レイアウト値を変更して、特定の値や高さだけではなく内容をラップします。 –