My texts in my layouts are overlapping or something and the text is cut off i'm not sure why, please help I'm making an app and i'm relatively new to XML so i need everything to look the same other then the text being cut off. I also put a screenshot of the layout so you can see what text is being cutoff.
Here is my XML file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:paddingBottom="0dp"
tools:context=".MainMenu"
android:background="#ffcf688f">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:src="@drawable/menuimage"
android:layout_alignBottom="@+id/toBattleButton"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView2"
android:src="@drawable/menuimage"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Store"
android:id="@+id/store"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textColor="@android:color/white"
android:textSize="60sp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Battle"
android:id="@+id/battle"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:textColor="@android:color/white"
android:textSize="60sp"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/toStoreButton"
android:background="@android:color/transparent"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/toBattleButton"
android:layout_alignTop="@+id/toStoreButton"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_alignLeft="@+id/battle"
android:layout_alignStart="@+id/battle"
android:background="@android:color/transparent"
android:singleLine="false"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/imageView2"
android:layout_centerHorizontal="true"
android:weightSum="5"
android:paddingBottom="15dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/menuText1"
android:editable="true"
android:textSize="20sp"
android:textColor="#ff9cf8ff"
android:textAlignment="center"
android:layout_gravity="center"
/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/menuText2"
android:textSize="20sp"
android:textColor="#ff9cf8ff"
android:layout_gravity="center"
android:textAlignment="center"
/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/menuText3"
android:textSize="20sp"
android:textColor="#ff9cf8ff"
android:layout_gravity="center"
android:textAlignment="center"
/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/menuText4"
android:textSize="20sp"
android:textColor="#ff9cf8ff"
android:layout_gravity="center"
android:textAlignment="center"
/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/menuText5"
android:textSize="20sp"
android:textColor="#ff9cf8ff"
android:layout_gravity="center"
android:textAlignment="center"
android:paddingTop="1dp"/>
</LinearLayout>
</LinearLayout>
I cant figure out why the text is cut off at the bottom (in blue)
答案 0 :(得分:0)
Trying using LinearLayout instead of RelativeLayout.
答案 1 :(得分:0)
如果您希望元素一个接一个地在相对布局中使用此属性
android:layout_below = "@+id/aboveElementId"
答案 2 :(得分:0)
您的布局嵌套在不需要的位置。
通过this article仔细阅读,了解每个TextView都没有必要使用LinearLayout。您应该意识到,您要完成的工作可以使用一个LinearLayout
,两个Space
和多个Textview
来完成。像这样:
<LinearLayout
android:orientation="vertical"
android:background="@drawable/menuimage"
...>
<Space
android:weight="1"
.../>
<TextView
.../>
<Space
android:weight="1"
.../>
<TextView
.../>
<TextView
.../>
<TextView
.../>
<TextView
.../>
<TextView
.../>
</LinearLayout>