Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJames N
17,864 Pointsmy linear layouts don't go into the center!
I am using android studio 1.0.1 and the linearLayouts aren't going into the center!
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="james.ribbit.loginActivity"
android:clickable="false"
style="@style/AuthBackground">
<include layout="@layout/auth_common"/>
<LinearLayout
android:id="@+id/editTextLayout"
style="@style/AuthFieldContainer"
android:layout_width="400dp"
android:layout_centerVertical="true">
<EditText
android:id="@+id/usernameField"
style="@style/Authedittext"
android:hint="@string/username_hint"
/>
<EditText
android:id="@+id/passwordField"
android:hint="@string/password_hint"
style="@style/Authedittext">
<requestFocus/>
</EditText>
</LinearLayout>
<Button
android:layout_width="400dp"
android:layout_centerVertical="true"
android:text="@string/login_button_label"
android:id="@+id/loginButton"
style="@style/AuthButton"
android:layout_below="@+id/editTextLayout"
android:layout_alignParentLeft="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sign_up_text"
android:id="@+id/signUpText"
android:textColor="@android:color/white"
android:layout_below="@+id/loginButton"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"/>
</RelativeLayout>
1 Answer
Douglas Rodriguez
23,577 PointsIn the linear layout, you have the following attribute: android:centerVertical="true". You are supposed to use android:centerHorizontal="true".