Próbuję wykonać czynność związaną z wprowadzeniem kodu PIN, ale jedna rzecz nie działa dla mnie. Nie mogę uzyskać tekst do centrum w TextView-tych na górze ekranu tutaj:Tekst w Androidzie TextView nie zostanie umieszczony na środku.
Droga będzie pracować jest, gdy użytkownik jest wprowadzenie kodu PIN, będę umieścić gwiazdę w każdej TextView dla widocznych informacji zwrotnych. Problem polega na tym, że chcę, aby gwiazda była wyśrodkowana. Próbowałem layout_gravity = "center", ale to nie robi różnicy. Oto mój obecny układ:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_height="wrap_content"
android:id="@+id/textView1"
android:text="PIN Required"
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="12sp"
></TextView>
<LinearLayout
android:layout_width="match_parent"
android:id="@+id/linearLayout1"
android:layout_height="wrap_content"
android:layout_marginBottom="12sp"
android:layout_gravity="center_horizontal"
>
<TextView
android:id="@+id/text1"
android:layout_height="32sp"
android:layout_width="48sp"
android:layout_weight="1"
android:layout_marginRight="2sp"
android:layout_marginLeft="48sp"
android:background="#FFFFFF"
android:text="X"
android:layout_gravity="center"
></TextView>
<TextView
android:id="@+id/text2"
android:layout_height="32sp"
android:layout_width="48sp"
android:layout_weight="1"
android:layout_marginRight="2sp"
android:layout_marginLeft="2sp"
android:background="#FFFFFF"
></TextView>
<TextView
android:id="@+id/text3"
android:layout_height="32sp"
android:layout_width="48sp"
android:layout_weight="1"
android:layout_marginRight="2sp"
android:layout_marginLeft="2sp"
android:background="#FFFFFF"
></TextView>
<TextView
android:id="@+id/text4"
android:layout_height="32sp"
android:layout_width="48sp"
android:layout_weight="1"
android:layout_marginRight="48sp"
android:layout_marginLeft="2sp"
android:background="#FFFFFF"
></TextView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:id="@+id/linearLayout2"
android:layout_height="wrap_content"
android:layout_marginBottom="12sp"
>
<Button
android:text="1"
android:textColor="#FFFFFF"
android:id="@+id/button1"
android:layout_height="32sp"
android:layout_width="64sp"
android:layout_weight="1"
android:editable="false"
android:layout_marginRight="2sp"
android:layout_marginLeft="48sp"
android:background="@drawable/action_background_gradient"
android:onClick="ButtonClicked"
></Button>
<Button
android:text="2"
android:textColor="#FFFFFF"
android:id="@+id/button2"
android:layout_height="32sp"
android:layout_width="64sp"
android:layout_weight="1"
android:editable="false"
android:layout_marginRight="2sp"
android:layout_marginLeft="2sp"
android:background="@drawable/action_background_gradient"
android:onClick="ButtonClicked"
></Button>
<Button
android:text="3"
android:textColor="#FFFFFF"
android:id="@+id/button3"
android:layout_height="32sp"
android:layout_width="64sp"
android:layout_weight="1"
android:editable="false"
android:layout_marginRight="48sp"
android:layout_marginLeft="2sp"
android:background="@drawable/action_background_gradient"
android:onClick="ButtonClicked"
></Button>
</LinearLayout>
<!--... and so on for the rest of the buttons ... -->
</LinearLayout>
mam, że Android: text = „x” w tam na pierwszym TextView tylko tak mogę sprawdzić, czy to działa. Kiedy skończę szczypanie układu, to zniknie. Jakiej prostej rzeczy brakuje?
To dlatego, że jestem knucklehead i chciałem powiedzieć TextView. Praca nad dwiema rzeczami naraz. Ale mam grawitację = "centrum" i nie działa. – MrGibbage
Doh! Mam układ_grawitacji, a nie tylko grawitację. Westchnienie ... Dzięki! – MrGibbage
Dzięki, to mi bardzo pomogło. – Kedarnath