2011-09-23 2 views
2

에 사용 가능한 모든 공간을 채우기 확인 :나는 이런 식으로 뭔가 원하는 구성 요소가 화면

enter image description here

을하지만 그것이 화면에 사용 가능한 모든 공간을 얻을 수 있도록하지 않습니다되는 텍스트 뷰의 크기를 조정하는 방법을 모른다 EditText 또는 버튼에 의해 ocuppied. 코드 또는 XML에서이 작업을 수행 할 수 있습니까?

XML에서 TextView를 FrameLayout에 넣으려고했지만 아무런 차이가 없습니다. 단추]를 리스너로 밀어 경우 그냥 확인하고있어 코드에서

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <FrameLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 

     <TextView 
      android:id="@+id/consola" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:scrollbars = "vertical" 
      android:text="@string/hello"/> 

    </FrameLayout> 

    <EditText 
     android:id="@+id/comando" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"/> 

    <LinearLayout 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 

     <Button 
      android:text="Conectar" 
      android:id="@+id/boton_conectar" 
      android:layout_width="wrap_content" 
      android:layout_weight="0.5" 
      android:layout_height="wrap_content"> 
     </Button> 
     <Button 
      android:text="Enviar" 
      android:id="@+id/boton_enviar" 
      android:layout_width="wrap_content" 
      android:layout_weight="0.5" 
      android:layout_height="wrap_content"> 
     </Button> 
    </LinearLayout> 
</LinearLayout> 

:처럼 현재 보입니다. 그 중 하나는 푸시 될 때 EditText에서 텍스트를 가져 와서 TextView에 추가합니다. 그것은 작동하고, TextView는 더 높아지고, EditText와 Buttons는 한 줄을 내립니다. 추가 행을 계속하면 마지막 EditText와 Buttons가 화면 밖으로 나옵니다. 이 동작을 피하고이 3 위젯을 화면 맨 아래에 붙여 넣으려고합니다.

+0

무엇 @dmon 말했다 (측면 노트. 0dp에 해당하는 높이/폭을 설정, 무게를 사용할 때 가끔 이상한 문제를 해결 도착), 플러스 당신은 수도 [상대적 레이아웃] (http://developer.android.com/resources/tutorials/views/hello-relativelayout.html)에서 뷰 계층 구조를 평평하게하려는 경우 - Eclipse의 Android UI 빌더가 추측에 상당히 능숙합니다. 일을 배치하는 방법, 상대 레이아웃이 지원하는 XML 속성도 확인하십시오. –

답변

2

양식 하단의 버튼과 마찬가지로 android:layout_weight=1 속성을 사용하십시오. 그러면 대부분의 공간과 나머지 요소에 남겨진 모든 것이 할당됩니다.

0

보십시오 android : fillViewport = "true".

2

모든 것이 무게에 관한 것입니다. 이것은 당신이 원하는 무엇을 제공해야합니다 :

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <TextView android:text="TextView" 
     android:id="@+id/textView1" 
     android:layout_weight="1" 
     android:layout_width="match_parent" 
     android:layout_height="0dp"> 
    </TextView> 
    <EditText android:id="@+id/editText1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
     <requestFocus></requestFocus> 
    </EditText> 
    <LinearLayout android:id="@+id/linearLayout1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
     <Button android:text="Button" 
      android:id="@+id/button1" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:layout_width="0dp"> 
     </Button> 
     <Button android:text="Button" 
      android:id="@+id/button2" 
      android:layout_height="wrap_content" 
      android:layout_width="0dp" 
      android:layout_weight="1"> 
     </Button> 
    </LinearLayout> 
</LinearLayout> 

:

관련 문제