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!我會。謝謝! –