我的活动中有一个google登录按钮。我在按钮的viewStart位置有一个google徽标。使用它可以将通常居中的文本偏离中心。
按钮xml:
<Button
android:id="@+id/signInBtn"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginStart="26dp"
android:layout_marginEnd="26dp"
android:layout_marginBottom="108dp"
android:background="@drawable/roung_bg"
android:drawableStart="@drawable/ic_google_logo"
android:elevation="@dimen/elevation"
android:text="@string/logIn"
android:textAlignment="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
我不满意并想将“登录”文本放在布局的中心。我怎样才能做到这一点?
您不应该使用drawbleStart,请使用两个视图来更改google徽标的大小或文字,示例的位置
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/colorAccent"
android:layout_marginStart="26dp"
android:layout_marginEnd="26dp"
android:layout_marginBottom="108dp">
<TextView
android:id="@+id/signInBtn"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#FFFFFF"
android:text="LOG IN"
android:textColor="#000000"
android:textAlignment="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:gravity="center"
android:layout_centerInParent="true"/>
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentStart="true"
android:background="@drawable/ic_google"
android:layout_centerVertical="true"/>
</RelativeLayout>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句