在以编程方式设置位图时,如何让imageView和textview都填充布局?

时间:2016-09-13 07:36:54

标签: android android-layout

我想要的是<div class="form-style-1"> <form name="frmUser" method="post" action=""> <input type="checkbox" name="users[]" value="1" > <input type="checkbox" name="users[]" value="2" > <input type="checkbox" name="users[]" value="3" > <input type="checkbox" name="users[]" value="4" > <input type="checkbox" name="users[]" value="5" > <input type="button" name="update" class="button" value="Update" onClick="checkAddress();" /> </form> </div>是否适合并显示qrcodetext中的所有文字,并qrcode_layout填充qrimageView的其余部分?但我的下面的布局包含整个qrcode_layout封面qrimageView。我尝试了一些其他的变化但没有成功。

这就是它的样子。

enter image description here

这就是我想要它的样子。

enter image description here

qrcode_layout

2 个答案:

答案 0 :(得分:1)

我认为我理解你想要的是下面的内容:Plz检查并告诉我:

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

    <LinearLayout
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:id="@+id/qrcodelayout">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:id="@+id/qrcodetext"
            android:gravity="center"            
            android:layout_weight="1"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="4dp" />
        <LinearLayout
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:orientation="vertical"
            android:layout_weight="1">
            <ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/qrimageView"                
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="8dp" />

        </LinearLayout>



    </LinearLayout>

    <!--<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
    </LinearLayout>-->

</RelativeLayout>

答案 1 :(得分:1)

使用以下代码。将文本视图对齐到底部,然后将Qrcode图像对齐文本:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">        
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/qrcodetext"
        android:gravity="center"
        android:layout_alignParentBottom="true"
        android:layout_marginTop="4dp" />        
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/qrimageView"
        android:layout_gravity="center_horizontal"
        android:layout_above="@id/qrcodetext"
        android:layout_alignParentTop="true"
        android:layout_marginTop="8dp" />
</RelativeLayout>