,在這裏不用我的一塊XML佈局:線性佈局centeralization
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="300dp">
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_payment_card_numbers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
>
</android.support.v7.widget.RecyclerView>
<TextView
android:layout_gravity="center_horizontal|center_vertical"
android:textSize="@dimen/secondary_text"
android:text="You have no credit cards"
android:textStyle="italic"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
我得到的佈局結果:
但我想垂直居中我的短信。 有什麼想法?
使用RelativeLayout的? –
@JyotmanSingh如果這是一個建議,我想使用線性佈局,如果它是一個問題,沒有沒有相對佈局我的XML。 – guisantogui
在你的linearlayout中添加這行代碼android:gravity =「'center | center_horizontal」 – Inducesmile