Один компонент макета XML не отображается - PullRequest
0 голосов
/ 01 октября 2018

У меня есть xml макет, и у меня есть некоторые проблемы.

Проблема первая:

Это пользователь для приложения чата. У меня есть LinearLayout, который содержит EditText .android Предварительный просмотр студии показывает это LinearLayout, нопри запуске приложения на моем устройстве не отображается.

Проблема вторая:

Я хочу добавить padding-right к EditText, чтобы убрать значок отправки. Я добавляю padding, но не работаю.

Проблема третья:

Как получить доступ к моему значку отправки в задании, чтобы установить для него OnClickListener.

Задача четвертая: Текст EditText выглядит жирным, хотя я не придаю ему жирный стиль.Это мой xml файл:

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
   >
    <android.support.v7.widget.RecyclerView
        android:id="@+id/reyclerview_message_list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    </android.support.v7.widget.RecyclerView>
    <LinearLayout
        android:id="@+id/layout_chatbox"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="48dp"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/edittext_chatbox"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:background="@drawable/rounded_edittext"
            android:drawableRight="@drawable/ic_upwards_arrow"
            android:hint="نوشتن پیام"
            android:maxLines="6"
            android:padding="5dip"
            android:textSize="14sp"
            android:textStyle="normal" />
    </LinearLayout>

</LinearLayout>

My output

Ответы [ 2 ]

0 голосов
/ 01 октября 2018

Проблема первая:

Используйте RelativeLayout в качестве корневого макета и сделайте layout_chatbox android:layout_alignParentBottom="true"

Проблема вторая:

Используйте ImageView вместо android:drawableRight, как показано в моем коде ниже

Проблема третья:

Теперь вы можете легко использовать OnClickListener для imageview

SAMPLE CODE

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


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/reyclerview_message_list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        </android.support.v7.widget.RecyclerView>


    </LinearLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@drawable/test"
        android:minHeight="48dp"
        android:padding="10dp">

        <EditText
            android:id="@+id/edittext_chatbox"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_toStartOf="@+id/ivsend"
            android:background="@android:color/transparent"
            android:hint="enter Text Here"
            android:maxLines="6"
            android:padding="5dp"
            android:textSize="14sp"
            android:textStyle="normal" />

        <ImageView
            android:id="@+id/ivsend"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentEnd="true"
            android:src="@drawable/ic_delete" />

    </RelativeLayout>

</RelativeLayout>

android: background ="@ drawable / test"

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" android:padding="10dp">
    <solid android:color="#FFFFFF"/>
    <corners
        android:radius="50dp"/>
</shape>

ВЫХОД

enter image description here

0 голосов
/ 01 октября 2018
Try this:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        >
        <LinearLayout
            android:id="@+id/layout_chatbox"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="48dp"
            android:orientation="horizontal"
            android:layout_alignParentBottom="true"
            >

         <RelativeLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
   >
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@mipmap/ic_launcher_round"
        android:layout_alignParentEnd="true"
        android:id="@+id/sendBtn"/>
    <EditText
        android:id="@+id/edittext_chatbox"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:background="@drawable/round"
        android:hint="نوشتن پیام"
        android:maxLines="6"
        android:padding="2dip"
        android:textSize="14sp"
        android:textStyle="normal"
        android:layout_toLeftOf="@id/sendBtn"
        android:layout_alignBottom="@id/sendBtn">
    </EditText>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/colorAccent"
        android:layout_below="@id/edittext_chatbox"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="5dip"
        />


</RelativeLayout>
        </LinearLayout>
        <android.support.v7.widget.RecyclerView
            android:id="@+id/reyclerview_message_list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_above="@id/layout_chatbox">

        </android.support.v7.widget.RecyclerView>


    </RelativeLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...