【发布时间】:2017-08-09 12:50:22
【问题描述】:
有什么方法可以让文本视图中的文本居中,然后让可绘制对象与左侧对齐,以便文本保持居中但可绘制对象不会影响这一点?目前整个文本视图正在居中。
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:elevation="4dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MirrorMirror"
android:textStyle="bold"
android:drawableLeft="@drawable/ic_mirror_face"
android:textAlignment="center"
android:textSize="20sp"
android:textColor="@android:color/white"
android:id="@+id/toolbar_title"
android:layout_gravity="center"/>
</android.support.v7.widget.Toolbar>
您可以在这张图片中看到问题。我希望单词以 Library 为中心。
【问题讨论】:
-
添加一个imageview并添加drawable作为背景并设置imageview重力左。
-
如果你愿意,我可以创建一个详细的答案。
-
是的,请! @布鲁诺费雷拉
-
试试我的代码@benjgorman
-
@benjgorman 为此使用单独的
ImageView和TextView不是更容易吗?
标签: android android-layout android-xml android-drawable