Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Layout problem  (Read 6646 times)
0 Members and 1 Guest are viewing this topic.
Offline drdracula
« Posted 2013-11-13 17:33:11 »

Hallo guys,
i am programming a Nokia 3310 app and I have a problem with the layout.

I want a fullscreen image of the Nokia 3310 on every device (2 - 10 inches), so I have choosen the Linear Layout, because I want also to have the buttons for every device on the right position:
http://s14.directupload.net/images/131113/9nlhxk62.png

With the linear layout I have used the weight (percent) to make it possible. The problem is that the weight makes the app very slow ("Nested weights are bad for performance").

Is there a way to solve my problem (with other layouts)? The most important thing is that i want to have the image of Nokia 3310 in fullscreen.



Sorry for my bad English.

The Nokia 3310 App: http://www.java-gaming.org/index.php/topic,31177




Programming, Design, Tutorials : http://www.matebox.bplaced.net
Offline Nate

JGO Kernel


Medals: 149
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #1 - Posted 2013-11-14 14:11:08 »

TableLayout works with Android:
https://github.com/EsotericSoftware/tablelayout
I found the built in layouts to be difficult to use solely via code.

FunnyCall uses it:
https://play.google.com/store/apps/details?id=com.gridmob.android.funnycall

Offline drdracula
« Reply #2 - Posted 2013-11-15 12:30:05 »

TableLayout works with Android:
https://github.com/EsotericSoftware/tablelayout
I found the built in layouts to be difficult to use solely via code.

FunnyCall uses it:
https://play.google.com/store/apps/details?id=com.gridmob.android.funnycall

Thank you for your answer.
I have solved my problem in an other way:
1. I have divided the height of the screen (e.g. Nexus 4: 1280px -96px (navigation bar) = 1184) through the x-position of the first point (x/y) see picture.
2. Then the width...
3. Step 1 and 2 with the second point (x2/y2)




At the end i got the quotients, which I have saved in arrays (double):
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
   //the width
   private double[] quotientX = {5.9, 2.4, 1.5, 5.9, 2.4, 1.5, 5.9, 2.4, 1.5, 5.9, 2.4, 1.5, 4.80, 2.95, 1.83, 1.54};
   private double[] quotientX2 ={2.8, 1.7, 1.2, 2.8, 1.7, 1.2, 2.8, 1.7, 1.2, 2.8, 1.7, 1.2, 2.79, 1.51, 1.45, 1.27};
   
   
   //the height
   private double[] quotientY = {1.60,1.55,1.60,
                          1.40,1.35,1.40,
                          1.25,1.20,1.25,
                          1.12,1.10,1.12,
                          1.97,2.23,1.86,2.02};
   
   private double[] quotientY2 = {1.50,1.40,1.50,
                           1.30,1.25,1.30,
                           1.15,1.10,1.15,
                           1.05,1.00,1.05,
                           1.85,2.01,1.67,1.77};

I haven't used buttons, but just the view:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
      image.setOnTouchListener(new OnTouchListener() {
         
         @Override
         public boolean onTouch(View v, MotionEvent event) {
           
            for(int i = 0; i < 16; i++){
               if(event.getX() > width/quotientX[i] && event.getX() < width/quotientX2[i] & event.getY() > height/quotientY[i] && event.getY() < height/quotientY2[i]){
                 
                  //1 to 9 buttons
                  if(i < 9){
                  Integer a = new Integer(i)+1;
                  view.setText(view.getText() + a.toString());
                  }
                 
                  //4th row buttons
                  else if(i == 9){
                     view.setText(view.getText() + "*");
                  }else if(i == 10){
                     view.setText(view.getText() + "0");
                  }else if(i == 11){
                     view.setText(view.getText() + "#");
                  }
                  //navigation buttons
                 
                     //delete button
                     else if(i == 12){
                        String s = view.getText().toString();
                        view.setText(s.substring(0, s.length() - 1));
                     }
                     //call button
                     else if(i == 13){
                        call();
                     }
                 
               }
           
            }
           
           
           
            return false;
         }
      });


This works with every device (every resolution and screen size). What do you think about it?

Programming, Design, Tutorials : http://www.matebox.bplaced.net
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (49 views)
2014-10-17 03:59:02

Norakomi (38 views)
2014-10-16 15:22:06

Norakomi (31 views)
2014-10-16 15:20:20

lcass (34 views)
2014-10-15 16:18:58

TehJavaDev (65 views)
2014-10-14 00:39:48

TehJavaDev (65 views)
2014-10-14 00:35:47

TehJavaDev (55 views)
2014-10-14 00:32:37

BurntPizza (72 views)
2014-10-11 23:24:42

BurntPizza (43 views)
2014-10-11 23:10:45

BurntPizza (84 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!