2012-10-21 7 views
0

다음 코드 여기에서설정 텍스트 상자의 폭이

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

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

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/firstNumber" 
     /> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     /> 

    </LinearLayout> 

</LinearLayout> 

에서 참조하시기 바랍니다 폭, 텍스트 상자의 크기 (폭)는 매우 작습니다. 남은 너비에 맞게 설정하려고하지만 볼 수 있듯이 실패합니다. 나는 android:weight=1도 사용했다. 제발 도와주세요, 어떻게 너비를 나머지 텍스트 상자의 너비를 설정할 수 있습니까?

답변

1

어쩌면 아래와 같이 수평 LinearLayout을 변경해야 할 수도 있습니다. match_parent

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

와 텍스트 뷰에 android:weight=1를 추가로 변경 폭은

+0

고맙습니다. 그게 도움이 됐어! +1 나 : –

1

는 시도이

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="fill_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:background="#FFFFFF" 
> 
<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    > 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/firstNumber" 
    android:layout_weight="0" 
    /> 

<EditText 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    /> 

</LinearLayout> 

+0

답장을 보내 주셔서 감사합니다. +1 나 : –

1

match_parent로 내부의 LinearLayout의 layout_width를주는 시도

android:layout_width="match_parent"

+0

답장을 보내 주셔서 감사합니다. +1 내게 :) –

관련 문제