简体   繁体   中英

Why is text in button starting so fa right that it is cut off?

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="com.example.app_talker_service.ConnectionManagerActivity" >

<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
        <TextView
            android:id="@+id/selectSenderTextView"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:layout_weight="1"
            android:text="@string/select_app_sender" />
        <TextView
            android:id="@+id/selectReceiverTextView"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:layout_weight="1"
            android:text="@string/select_app_receiver" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
        <Spinner 
            android:id="@+id/senderAppSpinner"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:layout_weight="1"/>
        <Spinner 
            android:id="@+id/receiverAppSpinner"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:layout_weight="1"/>
    </LinearLayout>
    <Button 
           android:id="@+id/checkConnectionsButton"
           android:layout_width="150dp"
           android:layout_height="60dp"
           android:layout_gravity="center"
           android:textSize="18sp"
           android:textStyle="bold"
           android:text="@string/check_connections"/>
</LinearLayout>

</ScrollView>

在此处输入图片说明

Why is the text in my button starting so far in the center that it gets cut off? I tried putting paddingleft and paddingright, textalignment, everything, but the only way that i don't get the text cut off is by making the button width way large..

Try this instead:

<Button 
    android:id="@+id/checkConnectionsButton"
    android:layout_width="150dp"
    android:layout_height="60dp"
    android:gravity="left"
    android:textSize="18sp"
    android:textStyle="bold"
    android:text="@string/check_connections"/>

Note: You can substitute android:gravity="center_horizontal" if you wish.

Also, you might want to decrease the textSize to 16sp or lower and see what you get.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM