2014-11-24 4 views
0

here에서 찾을 수있는 Android 용 부트 스트랩 라이브러리를 사용하고 있습니다. 필자의 응용 프로그램에 라이브러리를 가져 왔지만 버튼이 인 경우 전체 화면 너비가이되지 않습니다. Ive는 버튼을 나란히 놓고 android:layout_weight="1"을 사용했지만 버튼이 왼쪽으로 이동하고 늘어지지 않습니다. 심지어 android:layout_width="match_parent"을 사용해 보았지만 버튼의 높이가 커졌습니다. Android 버튼이 화면 너비에 미치지 못함

This is how my layout looks with the library

내가 설정 한 경우 일 것입니다

enter image description here

XML 코드

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:padding="20sp" > 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="318dp" 
    android:layout_height="wrap_content" 
    android:text="Send Pin To Email id." 
    android:textAppearance="?android:attr/textAppearanceMedium" /> 

<TextView 
    android:id="@+id/textView2" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="Enter Your Email Id Below" 
    android:textAppearance="?android:attr/textAppearanceMedium" /> 

<com.beardedhen.androidbootstrap.BootstrapEditText 
    android:id="@+id/et_email" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_margin="10dp" 
    android:ems="10" 
    android:hint="[email protected]" 
    android:inputType="textEmailAddress" 
    bootstrapbutton:be_roundedCorners="true" /> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center_horizontal" 
    android:orientation="horizontal" 
    android:paddingBottom="15sp" > 

    <com.beardedhen.androidbootstrap.BootstrapButton 
     android:id="@+id/OK" 
     style="@style/AppBaseTheme" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_margin="5dp" 
     android:text="OK" 
     bootstrapbutton:bb_icon_left="fa-envelope" 
     bootstrapbutton:bb_roundedCorners="true" 
     bootstrapbutton:bb_size="medium" 
     bootstrapbutton:bb_type="default" /> 

    <com.beardedhen.androidbootstrap.BootstrapButton 
     android:id="@+id/cancel" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_margin="10dp" 
     android:text="CANCEL" 
     bootstrapbutton:bb_icon_left="fa-times" 
     bootstrapbutton:bb_roundedCorners="true" 
     bootstrapbutton:bb_size="medium" 
     bootstrapbutton:bb_type="default" /> 
</LinearLayout> 

<View 
    android:layout_width="fill_parent" 
    android:layout_height="1dp" 
    android:background="@android:color/darker_gray" /> 

<TextView 
    android:id="@+id/textView3" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:paddingTop="15sp" 

    android:text="Got your Pin?Enter it below." 
    android:textAppearance="?android:attr/textAppearanceMedium" /> 

<com.beardedhen.androidbootstrap.BootstrapEditText 
    android:id="@+id/et_pin" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_margin="10dp" 
    android:ems="10" 
    android:hint="XXXX" 
    android:inputType="number" 
    bootstrapbutton:be_roundedCorners="true" /> 

<com.beardedhen.androidbootstrap.BootstrapButton 
    android:id="@+id/b_check" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:layout_margin="10dp" 
    android:text="Check" 
    bootstrapbutton:bb_icon_left="fa-check" 
    bootstrapbutton:bb_roundedCorners="true" 
    bootstrapbutton:bb_size="medium" 
    bootstrapbutton:bb_type="default" /> 

</LinearLayout> 
+0

어느 utton 당신은 streched해야합니까? 확인/취소 또는 확인 하시겠습니까? –

+0

@androidKiller 둘 다 실제로 .. 나는 'ok/cancel'을 나란히 (같은 크기로 너비를 채우는 것) 나란히 놓고 화면의 너비를 채우기 위해 '확인'하고 싶습니다. –

+0

주로 텍스트 크기에 사용되는 sp 대신 여백과 여백에 dp를 사용하십시오. –

답변

1

(확인 버튼) 및 android:layout_width="match_parent" (확인/취소에 대한) android:layout_width="0dip"android:layout_weight="1" 대신 너비를 0dip으로 사용해야합니다. weight 속성을 사용하는 경우 wrap_content입니다.

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center_horizontal" 
    android:orientation="horizontal" 
    android:paddingBottom="15sp" 
    android:weightSum="2"> 
    <com.beardedhen.androidbootstrap.BootstrapButton 
     android:id="@+id/OK" 
     style="@style/AppBaseTheme" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_margin="5dp" 
     android:text="OK" 
     bootstrapbutton:bb_icon_left="fa-envelope" 
     bootstrapbutton:bb_roundedCorners="true" 
     bootstrapbutton:bb_size="medium" 
     bootstrapbutton:bb_type="default" 
     android:layout_weight="1"/> 

    <com.beardedhen.androidbootstrap.BootstrapButton 
     android:id="@+id/cancel" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_margin="10dp" 
     android:text="CANCEL" 
     bootstrapbutton:bb_icon_left="fa-times" 
     bootstrapbutton:bb_roundedCorners="true" 
     bootstrapbutton:bb_size="medium" 
     bootstrapbutton:bb_type="default" 
     android:layout_weight="1"/> 

그리고 하나의 버튼에 대한

, 그냥 "match_parent"이 도움이

<com.beardedhen.androidbootstrap.BootstrapButton 
    android:id="@+id/b_check" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:layout_margin="10dp" 
    android:text="Check" 
    bootstrapbutton:bb_icon_left="fa-check" 
    bootstrapbutton:bb_roundedCorners="true" 
    bootstrapbutton:bb_size="medium" 
    bootstrapbutton:bb_type="default" /> 

희망으로 폭을 사용합니다.

+0

그것은 작동하지 않았다. .ive는 내가 당신의 코드를 추가 할 때 일어나는 일의 스크린 샷을 추가했다. –

+1

@Mike thanks :) 수정 됨 –

+0

@MysticMagic 나는 도서관 자체에 문제가 있다고 생각한다. 나는 당신의 코드가 정상적인 버튼을 위해 완벽하게 작동한다는 것을 알고 있으므로 이것을 정답으로 표시 할 것입니다. –