gpt4 book ai didi

android - 如何在布局的一角放置徽章图标

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:14:51 27 4
gpt4 key购买 nike

<分区>

我想在布局的一角放置一个徽章。我设法在布局内获得徽章,但无法在它的角落实现。

目前我的代码给我:

enter image description here

我想要的:我想让这个徽章位于布局的右上角。

我想要这样的东西:

enter image description here

Toolbar.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar 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="@dimen/toolbar_height"
android:background="@color/toolbar_color"
android:contentInsetLeft="0dp"
android:contentInsetStart="0dp"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textview"
android:text="My Assignments"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginLeft="90dp"
android:layout_weight="0.5"
android:textSize="20sp"
/>

<RelativeLayout
android:id="@+id/bell_linearlayout1"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_gravity="center"
android:layout_marginLeft="15dp">

<RelativeLayout
android:id="@+id/bell_linearlayout"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:background="#75aadb">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_centerInParent="true"
android:id="@+id/cartIconImageView"
android:src="@drawable/notification"/>
</RelativeLayout>

<RelativeLayout
android:layout_width="25dip"
android:layout_height="25dip"
android:gravity="end|top|right"
android:layout_alignParentTop="true"
android:layout_marginBottom="100dp"
android:layout_marginLeft="20dp">

<TextView
android:id="@+id/textView1"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignParentTop="true"
android:background="@drawable/badge" />
</RelativeLayout>

</RelativeLayout>
<LinearLayout
android:layout_width="35dp"
android:layout_height="35dp"
android:background="#75aadb"
android:id="@+id/accountinfo_layout"
android:layout_gravity="center"
android:layout_marginLeft="10dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:src="@drawable/profile"/>

</LinearLayout>


</LinearLayout>
</android.support.v7.widget.Toolbar>

Drawable badge.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="8dp" />
<solid android:color="#f20000" />
<stroke
android:width="2dip"
android:color="#FFF" />
<padding
android:bottom="6dp"
android:left="6dp"
android:right="6dp"
android:top="6dp" />
</shape>

请帮忙。

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com