Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Button not showing in android app

    • 0
    • 0
    • 0
    • 3
    • 0
    • 0
    • 0
    • 1.52k
    Answer it

    Hello I have created six buttons in an app in android studio inside the Relative Layout. The buttons show OK in the preview mode of android studio but they second last one does not show when I install my app to test on a phone or an emulator. What could be the problem
    Here is my code

     

    <?xml version="1.0" encoding="utf-8"?>
        <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="wrap_content"
            android:paddingBottom="@dimen/activity_vertical_margin"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:paddingTop="@dimen/activity_vertical_margin"
            tools:context="com.example.nelson.kuzaapp.MainActivity">
    
            <ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:src="@drawable/logoo"
                android:contentDescription="@string/logo"
                android:id="@+id/logo"
                android:layout_marginTop="-500dp"
                />
           <!--Make query button-->
            <Button
                style="?android:textAppearanceSmall"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="150dp"
                android:text="@string/make_farming_query"
                android:id="@+id/buttonAskExpert"
                android:layout_below="@+id/logo"
                android:layout_alignParentTop="true"
                android:layout_alignParentRight="true"
                android:layout_alignParentEnd="true"
                />
            <!--View products Button-->
            <Button
                style="?android:textAppearanceSmall"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:text="@string/view_products"
                android:id="@+id/buttonViewProducts"
                android:layout_below="@+id/buttonAskExpert"
                android:layout_alignLeft="@+id/buttonAskExpert"
                android:layout_alignStart="@+id/buttonAskExpert"
                />
    <!--Farmer Login button-->
            <Button
                style="?android:textAppearanceSmall"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:text="@string/farmer_login"
                android:id="@+id/buttonFarmerLogin"
                android:layout_below="@+id/buttonViewProducts"
                android:layout_alignLeft="@+id/buttonViewProducts"
                android:layout_alignStart="@+id/buttonViewProducts" />
    <!--Farmer registration-->
            <Button
                style="?android:textAppearanceSmall"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:text="@string/farmer_registration"
                android:id="@+id/buttonRegisterFarmer"
                android:layout_below="@+id/buttonFarmerLogin"
                android:layout_alignLeft="@+id/buttonFarmerLogin"
                android:layout_alignStart="@+id/buttonFarmerLogin" />
    <!-- Twitter button-->
            <Button
                style="?android:textAppearanceSmall"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:text="@string/follow_us_on_twitter"
                android:id="@+id/buttonFollowTwitter"
                android:layout_below="@+id/buttonRegisterFarmer"
                android:layout_alignLeft="@+id/buttonRegisterFarmer"
                android:layout_alignStart="@+id/buttonRegisterFarmer" />
    <!--Facebook button-->
            <Button
                style="?android:textAppearanceSmall"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:text="@string/like_us_on_facebook"
                android:id="@+id/buttonLikeFacebook"
                android:layout_below="@+id/buttonFollowTwitter"
                android:layout_alignLeft="@+id/buttonFollowTwitter"
                android:layout_alignStart="@+id/buttonFollowTwitter" />
    
    
        </RelativeLayout>
    

 3 Answer(s)

  • Did you attach the same layout in your activity or fragment. Please share the code of your Activity/Fragment too.
    If you are attaching the same layout then you can try the following points:-

    • Remove layout_marginTop="-500dp" from the imageview
    • Use wrap_content Instead of giving match_parent to the width and height of imageview
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: