Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
HTML
    <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" />


    


What I have tried:

I have tried to add a Scroll View before the Relative Layout and even changing the width and height sizes to be the same
Posted
Updated 10-Mar-17 23:15pm
Comments
Richard MacCutchan 20-Nov-16 3:44am    
Your XML is not complete.
wseng 20-Nov-16 9:47am    
paste your complete xml
Mike (Prof. Chuck) 25-Nov-16 15:35pm    
What is the hardcoded margin of -500dp?
This is not a very good design - always think relative, do alignParentTop or something similar.
Take that -500 out - I am very sure, you just have a different resolution on your physical device than on the preview screen and therefore the button somehow falls off the screen.

1 solution

I have realized that the hidden buttons have an app installed listener configured to check if the app is instaled in order to display the button. And since tweeter is not installed, the tweeter button disappears
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900