Как отобразить вид сверху на другой? - PullRequest
0 голосов
/ 29 апреля 2018

Что я пробовал и как это видно сейчас :

enter image description here

Код, который у меня есть (программно я могу выделить красную область) :

<?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">

    <LinearLayout
        android:id="@+id/linearLayoutInbox"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center">

        <FrameLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">


            <TextView
                android:id="@+id/textViewInbox"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="INBOX"
                android:textColor="#000000"
                android:layout_gravity="center_horizontal|bottom"
                android:textSize="12sp" />

            <TextView
                android:id="@+id/txtNewMsgId"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:textSize="8sp"
                android:layout_gravity="bottom|right"
                android:textColor="#000000"
                android:letterSpacing="0.1"
                android:text="14"
                android:gravity="center"
                android:layout_marginBottom="4dp"
                android:padding="2dp"/>

        </FrameLayout>



    </LinearLayout>

</LinearLayout>

Чего я пытаюсь достичь: Позиция 14 не в совершенстве и в верхней части входного почтового ящика (Как этого добиться)

enter image description here

Ответы [ 3 ]

0 голосов
/ 29 апреля 2018

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

Упрощенный код:

<android.support.constraint.ConstraintLayout>

    <TextView
        android:id="@+id/inbox"
        android:text="inbox"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"/>

    <TextView
        android:text="14"
        app:layout_constraintLeft_toLeftOf="@id/inbox"
        app:layout_constraintRight_toRightOf="@id/inbox"
        app:layout_constraintTop_toTopOf="@id/inbox"
        app:layout_constraintBottom_toBottomOf="@id/inbox"
        app:layout_constraintVertical_bias="1"
        app:layout_constraintHorizontal_bias="1"
        //add some margins to push it over the "inbox" borders. />

</android.support.constraint.ConstraintLayout>
0 голосов
/ 01 мая 2018

Здравствуйте, я нашел эту библиотеку, которая помогает вашему требованию

compile 'com.allenliu.badgeview: библиотека: 1.1.1'

и вы можете настроить в соответствии с вашими требованиями, как это

BadgeFactory.create(this)
.setTextColor(Color.White)
.setWidthAndHeight(25,25)
.setBadgeBackground(Color.Red)
.setTextSize(10)
.setBadgeGravity(Gravity.Right|Gravity.Top)
.setBadgeCount(20)
.setShape(BadgeView.SHAPE_CIRCLE)
.setSpace(10,10)
.bind(view);// you can pass View object that can be Textview ImageView Button etc... 
0 голосов
/ 29 апреля 2018

Просто добавьте отступ 10dp в textviewinbox. Вы можете установить этот отступ в соответствии с требованиями вашего представления. Может быть, это решит вашу проблему

...