skip to Main Content

I have already designed a user interface for my app in Photoshop. Then I added the user interface to Android Studio as a background image. Then I added some buttons in such a way that it is right over the the button in the user interface. Then, when I switched it to a different device, the button placement got messed up! Can anyone help me?
I tried using LinearLayout, but that didn’t work!
So when someone uses my app they will click on the button, they will be only clicking the image. Please help!

3

Answers


  1. What you are doing is not correct way actually, you have photoshoped your layout now you don’t have to set it as an Image background, instead you must create your own layout by using Layouts define in android and widgets and then you have to manage click and all stuff, As your Image background will expand and collapse on different screen sizes you will never get appropriate click events on them and it’s not a way to design App.

    So, Create your design using widgets, use styles and layouts and create design using XML files.

    Official documentation here and nice tutorial to get understanding is here

    Login or Signup to reply.
  2. The best way to design for different screen sizes is to separate the background image from the widgets. This allows you to have a full control of your interface. Hope you get it

    Login or Signup to reply.
  3. Don’t put interface screen to background. Instead of that, use only background image. And, you can use RelativeLayout for this. There is also programmatically way. You should get screen sizes, and after then,measure x,y of image which in your interface background. Then, if view’s left in 1/4 part of screen, you can do this like:

    ImageView imageView = (ImageView) findViewById(R.id.imageView);
    RelativeLayout.LayoutParams lp= new RelativeLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
    lp.leftMargin = screenWidth/4;
    imageView.setLayoutParams(lp);
    

    If you don’t have another way only then use this way. Because, writing design codes in xml is most efficiently way.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search