user2286261 user2286261 - 2 months ago 26
Android Question

error: Error: String types not allowed (at 'layout_gravity' with value 'start')

I would like to implement a navigation drawer but in my xml file
I get this error:

error: Error: String types not allowed (at 'layout_gravity' with value
'start').

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<!-- The main content view -->


<RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".NeueNotizActivity" >

<EditText
android:id="@+id/editDocuTitleNewDocu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:ems="10"
android:inputType="text"
android:hint="@string/Docu.title" >

<requestFocus />
</EditText>

<View
android:id="@+id/ViewColorPickerHelper"
android:layout_width="1dip"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="4dip"
android:layout_marginTop="410dip"
android:background="?android:attr/dividerVertical" />



<Button
android:id="@+id/btSaveNewDocu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/btAbortNewDocu"
android:background="?android:attr/selectableItemBackground"
android:onClick="speichern"
android:text="@string/Docu.save"
android:drawableLeft="@android:drawable/ic_input_add" />



</RelativeLayout>

<!-- The navigation drawer -->

<ListView
android:id="@+id/drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#F3F3F4"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />

</android.support.v4.widget.DrawerLayout>


I hope you can help.
When I delete this: android:layout_gravity="start" then the menu do not work.

Answer

Start is actually valid: http://developer.android.com/reference/android/widget/LinearLayout.LayoutParams.html#attr_android:layout_gravity

However I've only seen it used when account for languages that read right to left, otherwise use left like the following :

android:layout_gravity="left"

Hope that helps.

Comments