以下代碼與EditText組件在其框中垂直軸上的引力不匹配。EditText重力不適用於wrap_content
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:text="Test" />
</RelativeLayout>
是否有任何解決方法具有休耕屬性和文本居中?
這可能不是第一次可以看到,但我有兩個與高度WRAP_CONTENT center_vertical但在第一個例子中的文本在其框中definetly中心,並在第二它很關閉。
EDIT2:
<carbon.widget.LinearLayout
android:id="@+id/linearLayout_login_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/general_footer_P"
android:background="@android:color/transparent"
android:orientation="vertical">
<carbon.widget.TextView
android:id="@+id/textView_login_footer_info1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:carbon_fontFamily="sans-serif-light"
android:gravity="center_horizontal|center_vertical"
android:text="@string/activity_footer_bottom_info1"
android:textColor="@color/text_edit"
android:textSize="@dimen/general_footer_size_P" />
<carbon.widget.LinearLayout
android:id="@+id/linearLayout_login_footer_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:orientation="horizontal">
<carbon.widget.TextView
android:id="@+id/textView_login_footer_info2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:carbon_fontFamily="sans-serif-light"
android:text="@string/activity_footer_bottom_info2"
android:textColor="@color/text_edit"
android:textSize="@dimen/general_footer_size_P" />
<carbon.widget.TextView
android:id="@+id/textView_login_footer_info3_link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:autoLink="all"
app:carbon_fontFamily="sans-serif-light"
android:text="@string/activity_footer_bottom_info3"
android:textColor="@color/link"
android:textSize="@dimen/general_footer_size_P" />
</carbon.widget.LinearLayout>
</carbon.widget.LinearLayout>
<carbon.widget.LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/linearLayout_login_footer"
android:layout_alignParentTop="true"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="@integer/login_layout_weight_sum_P">
<carbon.widget.LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="@integer/login_layout_left_margin_weight_P" />
<carbon.widget.LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="@integer/login_layout_weight_P"
android:orientation="vertical">
<carbon.widget.Button
android:id="@+id/button_login_facebook"
android:layout_width="match_parent"
android:layout_height="@dimen/login_button_height_P"
android:layout_marginBottom="@dimen/login_layout_button_bottom_margin_P"
android:background="@color/facebook_main"
android:drawableLeft="@drawable/icons_fb_icon_on"
android:drawableStart="@drawable/icons_fb_icon_on"
app:carbon_fontFamily="sans-serif-light"
android:text="@string/activity_login_facebook_login"
app:carbon_textAllCaps="false"
android:textColor="@color/text_white"
android:textSize="@dimen/login_button_text_size_P" />
<carbon.widget.Button
android:id="@+id/button_login_twitter"
android:layout_width="match_parent"
android:layout_height="@dimen/login_button_height_P"
android:layout_marginBottom="@dimen/login_layout_button_bottom_margin_P"
android:background="@color/twitter_main"
android:drawableLeft="@drawable/icons_twitter_icon_on"
android:drawableStart="@drawable/icons_twitter_icon_on"
app:carbon_fontFamily="sans-serif-light"
android:text="@string/activity_login_twitter_login"
app:carbon_textAllCaps="false"
android:textColor="@color/text_white"
android:textSize="@dimen/login_button_text_size_P" />
<carbon.widget.EditText
android:id="@+id/editText_login_email"
android:layout_width="match_parent"
android:layout_height="@dimen/login_button_height_P"
android:layout_marginBottom="@dimen/login_layout_button_bottom_margin_P"
android:background="@color/button_white"
android:cursorVisible="true"
android:ellipsize="end"
app:carbon_fontFamily="sans-serif-light"
android:gravity="center"
android:hint="@string/activity_login_email_hint"
android:inputType="textEmailAddress"
android:textColor="@color/text_edit"
android:textColorHint="@color/text_footer"
android:textCursorDrawable="@null"
android:textSize="@dimen/login_button_text_size_P"
android:singleLine="true" />
<carbon.widget.EditText
android:id="@+id/editText_login_password"
android:layout_width="match_parent"
android:layout_height="@dimen/login_button_height_P"
android:layout_marginBottom="@dimen/login_layout_button_bottom_margin_P"
android:background="@color/button_white"
android:cursorVisible="true"
android:ellipsize="end"
app:carbon_fontFamily="sans-serif-light"
android:gravity="center"
android:hint="@string/activity_login_password_hint"
android:inputType="textPassword"
android:textColor="@color/text_edit"
android:textColorHint="@color/text_footer"
android:textCursorDrawable="@null"
android:textSize="@dimen/login_button_text_size_P"
android:singleLine="true"/>
<carbon.widget.Button
android:id="@+id/button_login_login"
android:layout_width="match_parent"
android:layout_height="@dimen/login_button_height_P"
android:layout_marginBottom="@dimen/login_layout_button_bottom_margin_P"
android:background="@drawable/shadow_border_blue_panel"
app:carbon_fontFamily="sans-serif"
android:text="@string/activity_login_LOGIN"
android:textColor="@color/text_white"
android:textSize="@dimen/login_button_text_size_P" />
<carbon.widget.TextView
android:id="@+id/textView_login_forgot_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/login_layout_forgot_password_margin_top_P"
app:carbon_fontFamily="sans-serif-light"
android:gravity="center_horizontal|center_vertical"
android:text="@string/activity_login_forgot_password"
android:textColor="@color/text_edit"
android:textSize="@dimen/login_layout_forgot_password_text_size_P" />
</carbon.widget.LinearLayout>
<carbon.widget.LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="@integer/login_layout_right_margin_weight_P" />
</carbon.widget.LinearLayout>
</carbon.widget.RelativeLayout>
的完整代碼didnt適合:/ 我得到肯定其作者
你想要什麼?在哪裏對齊你的文字? – justDroid
由於我剛纔看到我的問題還不清楚 –
@TomaszJuszczak屏幕截圖將會更好 –