工具栏后退箭头带有图标

时间:2018-08-05 21:57:50

标签: java android android-custom-view android-toolbar

如何在类似WhatsApp的android工具栏中显示带有后退箭头的图标? 我想缩小照片和后退箭头之间的空间。 如何减少空间? 我有:

  • ChatActivity.java :布局(只有一个视图)被ChatFragment.java取代。此外,工具栏在这里替换为fragment_chat_toolbar.xml
  • ChatFragment.java :此处管理输入,表情符号,文件等

谢谢。

My toolbar chat

fragment_chat.xml

<LinearLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:id="@+id/layout_chat"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" >

  <android.support.v7.widget.RecyclerView
    android:id="@+id/fragment_chat_recycler_view"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_weight="1"/>

  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_marginBottom="4dp"
    android:layout_marginLeft="4dp"
    android:layout_marginRight="4dp"
    android:gravity="center" >

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:orientation="horizontal"
        android:layout_marginEnd="4dp"
        android:background="@drawable/incoming_message"
        android:baselineAligned="false">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:paddingBottom="2dp"
            android:paddingStart="2dp"
            android:paddingEnd="4dp" >

            <ImageView
                android:id="@+id/image_view_emoji"
                android:layout_width="28dp"
                android:layout_height="28dp"
                android:layout_marginStart="6dp"
                android:layout_gravity="center"
                android:contentDescription="@string/emoji_button"
                android:src="@mipmap/ic_emoji"
                android:tint="@color/total_black" />

            <com.vanniktech.emoji.EmojiEditText
                android:id="@+id/message_box_emoji"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_margin="8dp"
                android:layout_weight="1"
                android:background="@color/incomingColor"
                android:hint="@string/send_message"
                app:emojiSize="26sp"/>

            <ImageView
                android:id="@+id/image_view_camera"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="6dp"
                android:layout_gravity="center"
                android:contentDescription="@string/camera_button"
                android:src="@mipmap/ic_camera"
                android:tint="@color/total_black" />

        </LinearLayout>
    </LinearLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/float_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end|bottom"
        android:src="@mipmap/ic_voice_recorder"
        android:tint="@color/white"
        app:backgroundTint="@color/colorPrimary"
        app:elevation="0dp"
        app:fabSize="mini"/>
</LinearLayout>



</LinearLayout>

fragment_chat_toolbar.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:clipChildren="false" >

<com.facebook.drawee.view.SimpleDraweeView
    android:id="@+id/profile_photo"
    android:layout_width="50dp"
    android:layout_height="50dp"
    fresco:failureImage="@drawable/default_profile"
    fresco:placeholderImage="@drawable/default_profile"
    fresco:roundAsCircle="true" />

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginStart="4dp"
    android:gravity="start"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/chat_title_text_view"
        android:layout_width="wrap_content"
        android:textSize="16sp"
        android:layout_height="wrap_content"
        android:maxLines="1"
        android:textColor="@color/white" />

    <TextView
        android:id="@+id/chat_subtitle_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:maxLines="1"
        android:textColor="@color/white" />
</LinearLayout>

1 个答案:

答案 0 :(得分:0)

根据需要设置“自定义工具栏”。在RelativeLayout中更改布局

svc = re.search(r'SVC:(.*?)]', mytext)
smc = re.search(r'SMC:(.*?)]', mytext)
act = re.search(r'ACT:(.*?)]', mytext)
binf = re.search(r'BINF:(.*?)]', mytext)
fid = re.search(r'FID:(.*?)]', mytext)
from1 = re.search(r'from:(.*?)]', mytext)
to1 = re.search(r'to:(.*?)]', mytext)
flags = re.search(r'flags:(.*?)]', mytext)
msg = re.search(r'msg:(.*?)\s', mytext)
sub = re.search(r'sub:(.*?)\s', mytext)
dlvrd = re.search(r'dlvrd:(.*?)\s', mytext)
submit_date = re.search(r'submit date:(.*?)\s', mytext)
done_date = re.search(r'done date:(.*?)\s', mytext)
stat = re.search(r'stat:(.*?)\s', mytext)
err = re.search(r'err:(.*?)\s', mytext)
text = re.search(r'text:(.*?)]', mytext)
udh = re.search(r'udh:(.*?)]', mytext)

mydict=dict()

mydict['SVC'] = svc.groups()[0]
mydict['SMC'] = smc.groups()[0]
mydict['ACT'] = act.groups()[0]
mydict['BINF'] = binf.groups()[0]
mydict['FID'] = fid.groups()[0]
mydict['from'] = from1.groups()[0]
mydict['to'] = to1.groups()[0]
mydict['flags'] = flags.groups()[0]
mydict['msg'] = msg.groups()[0]
mydict['sub'] = sub.groups()[0]
mydict['dlvrd'] = dlvrd.groups()[0]
mydict['submit_date'] = submit_date.groups()[0]
mydict['done_date'] = done_date.groups()[0]
mydict['stat'] = stat.groups()[0]
mydict['err'] = err.groups()[0]
mydict['text'] = text.groups()[0]
mydict['udh'] = udh.groups()[0]