ボタンの余白を無視して、複数行のボタンテキストの問題

MaxxOr:

基本的に私は改行を引き起こし、かなり長い文字列とボタンがあります。ボタンは、ボタンは親の全幅を占めるようしかし、このような複数回線ボタンのテキストを無視され、左余白と右を持っています。

明らか解決策は、しかし、ボタンはもはや包まれbuttontext短いために意味幅静的を強制0dpにレイアウト幅を設定することです。

幅のためwrap_contentを保つが、まだ余裕が無視されていないためにどのように良いの解決策はありますか?

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android">

<Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="32dp"
        android:layout_marginRight="32dp"
        android:text="@string/longstring"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />


</androidx.constraintlayout.widget.ConstraintLayout>
ウスマン勝利:

ボタンは、マージンを尊重するように、ボタンのXMLに次の行を追加します。

app:layout_constrainedWidth="true"

出力

ここでは、画像の説明を入力します。

おすすめ

転載: http://10.200.1.11:23101/article/api/json?id=394100&siteId=1
おすすめ