我遇到一个问题,我的一个linearLayout ImageView重叠了另一个linearLayout的Button。有没有人知道如何在没有重叠的情况下将元素放在另一个上面?我已经尝试了android:layout_above="@+id/overlappedButton"
但是imageView仍然与我的LinearLayout按钮重叠。这是我的代码,第二个imageview下应该有三个按钮,但是现在只有一个可见。提前谢谢。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fragment_splash"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
android:gravity="center"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:layout_marginTop="0dp">
<ImageView
android:id="@+id/gherboicon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:src="@drawable/splash_icon"
android:visibility="invisible"/>
<ImageView
android:id="@+id/gherbo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:src="@drawable/splash_pic"
android:layout_above="@+id/splash_screen_buttons"
android:visibility="invisible"/>
<LinearLayout
android:id="@+id/splash_screen_buttons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:visibility="invisible">
<Button
android:id="@+id/sign_up_splash"
android:layout_width="140dp"
android:layout_height="40dp"
android:layout_marginBottom="15dp"
android:background="@drawable/bg_login_red"
android:onClick="signup"
android:text="Sign Up"
android:textColor="@android:color/holo_red_dark" />
<Button
android:id="@+id/login_splash"
android:layout_width="140dp"
android:layout_height="40dp"
android:layout_marginBottom="15dp"
android:background="@drawable/bg_login_white"
android:onClick="login"
android:text="@string/btn_signin"
android:textColor="@drawable/txt_login_white" />
<Button
android:id="@+id/skip_now_splash"
android:layout_width="140dp"
android:layout_height="40dp"
android:background="@android:color/transparent"
android:onClick="skipNow"
android:text="Skip for now"
android:textColor="@color/charcoal" />
</LinearLayout>
答案 0 :(得分:0)
Use the following architecture in your xml file:
<RelativeLayout
<LinearLayout>
<ImageView/>
<ImageView/>
</LinearLayout>
<LinearLayout
android:layout_below="@+id/linearLayoutOne">
<Button/>
<Button/>
<Button/>
</LinearLayout>
</RelativeLayout>
After wrapping both of your linearLayouts into a relative layout, you will be able to create a relationship behavior by putting your second LinearLayout below your first one.
答案 1 :(得分:0)
Add ScrollView to make the LinearLayout Scrollable
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fragment_splash"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="0dp"
android:background="@android:color/black"
android:gravity="center"
android:orientation="vertical"
android:paddingLeft="0dp"
android:paddingRight="0dp">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/gherboicon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:src="@drawable/splash_icon"
android:visibility="invisible"/>
<ImageView
android:id="@+id/gherbo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/splash_screen_buttons"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:src="@drawable/splash_pic"
android:visibility="invisible"/>
<LinearLayout
android:id="@+id/splash_screen_buttons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:visibility="invisible">
<Button
android:id="@+id/sign_up_splash"
android:layout_width="140dp"
android:layout_height="40dp"
android:layout_marginBottom="15dp"
android:background="@drawable/bg_login_red"
android:onClick="signup"
android:text="Sign Up"
android:textColor="@android:color/holo_red_dark" />
<Button
android:id="@+id/login_splash"
android:layout_width="140dp"
android:layout_height="40dp"
android:layout_marginBottom="15dp"
android:background="@drawable/bg_login_white"
android:onClick="login"
android:text="@string/btn_signin"
android:textColor="@drawable/txt_login_white" />
<Button
android:id="@+id/skip_now_splash"
android:layout_width="140dp"
android:layout_height="40dp"
android:background="@android:color/transparent"
android:onClick="skipNow"
android:text="Skip for now"
android:textColor="@color/charcoal" />
</LinearLayout>
</LinearLayout>
</ScrollView>