试图让按钮对话框进行后评论

问题描述 投票:0回答:1

我想送类似于Instagram的注释部分按钮。但是当我运行的应用程序仅文本字段出现。

下面是我的XML

Popup.xml:

<?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"
    android:gravity="center"
    android:background="@drawable/dialog_bg"
    android:padding="10px">
//Receive the comment from Api
    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/popup_rcv">
    </android.support.v7.widget.RecyclerView>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_gravity="bottom">
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/new_comment_et"
            android:hint="Please enter Comment"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/comment_btn"
            android:text="Submit"
            />
    </LinearLayout>
</LinearLayout>

提前致谢

android android-layout
1个回答
2
投票

我想送类似于Instagram的注释部分按钮。但是当我运行的应用程序仅文本字段出现。

因为你的EditText宽度match_parent只是增加一些重量在EditText

只需在您的android:layout_weight="1"添加EditText

样品编号

<?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"
    android:gravity="center"
    android:background="@drawable/dialog_bg"
    android:padding="10px">
//Receive the comment from Api
    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/popup_rcv">
    </android.support.v7.widget.RecyclerView>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_gravity="bottom">
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/new_comment_et"
            android:layout_weight="1"
            android:hint="Please enter Comment"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/comment_btn"
            android:text="Submit"
            />
    </LinearLayout>
</LinearLayout>
© www.soinside.com 2019 - 2024. All rights reserved.