-2

チャットバブルで画面を構築しようとしています。問題はandroid:layout_centerHorizontal="true"、バブルが正確に中央に達し、テキストのサイズに基づいて両方向に拡大する場合です。しかし、このバブルの中心を画面または親レイアウトの中心に 20 dp 固定したいと考えています。

<View
                android:id="@+id/anchor"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_centerHorizontal="true" />
            <TextView
                android:id="@+id/textview"
                android:text="Some Text"
                style="Style_with_layout_height_width_etc"
                android:layout_alignParentBottom="true"
                android:layout_alignStart="@+id/anchor"
                android:layout_marginStart="-20dp"
                android:layout_marginBottom="20dp"/>

幅と高さが0dpのアンカービューを使用するなどの方法を試しましたが、役に立ちません。

EDIT-1 : さらに参照するために XML コードを追加

EDIT-2 : 制約レイアウトを使用し、水平バイアスを設定すると、問題の解決に役立ちました。

4

1 に答える 1

0

ConstraintLayoutニーズに合わせてビューの位置を正確に調整するには、 new を使用することを検討してください。

参照 - https://developer.android.com/training/constraint-layout/index.html

于 2016-09-26T09:57:55.140 に答える