0
我希望你能帮助我,因为这是推动我坚果...RelativeLayout的推压中心查看到右
我有一个简单RelativeLayout
有两个子视图,你可以将代码样本中看到。 TextView
应该是居中和ProgressBar
左对齐。
在布局编辑器中,这是正确渲染的,但在设备/仿真器上TextView
被推到右边,并且ProgressBar
也有一个随机偏移量。
你可以忽略文本和按钮颜色不同的事实,我已经检查过这没有什么区别。
<RelativeLayout
android:id="@+id/popup_redeem_button"
android:layout_margin="@dimen/margin_outer"
android:background="@drawable/button_rounded_yellow"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<de.fireflow.milebox.ui.views.TypefaceTextView
android:id="@+id/popup_redeem_text"
style="@style/ButtonHeadlineMenu_Font"
app:richText="true"
android:padding="@dimen/margin_normal"
android:text="@string/voucher_redeem"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/margin_normal"
android:indeterminateBehavior="cycle"
android:layout_gravity="center_horizontal"/>
</RelativeLayout>
形状的按钮背景:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:radius="6dp"
/>
<solid
android:color="@color/btn_yellow_pressed"
/>
</shape>
我不衡量或更改任何布局界限的代码,所以我真的不认为这个问题的。有任何想法吗?
尝试将自定义'TextView'的'layout_width'更改为''match_parent“',并将其'gravity'设置为'center_horizontal'。 –
谢谢,这真的解决了这个问题。简单但高效:D。如果你添加它作为答案,我会接受它 – McLovin
哦,neato!我会。谢谢! –