Android: Layout_Height 50% der BildschirmgrößeAndroid

Forum für diejenigen, die für Android programmieren
Guest
 Android: Layout_Height 50% der Bildschirmgröße

Post by Guest »

Ich habe gerade eine ListView in einem Linearlayout implementiert, aber ich muss die Höhe des Linearlayouts definieren (es muss 50% der Bildschirmhöhe sein). < /p>

Code: Select all






< /code>

Ist das möglich? an Layouts zu arbeiten. < /p>

Dies ist mein Code: < /p>

    //capture the size of the devices screen
Display display = getWindowManager().getDefaultDisplay();
double width = display.getWidth();

//my EditText will be smaller than full screen (80%)
double doubleSize = (width/5)*4;
int editTextSize = (int) doubleSize;

//define the EditText
userName = (EditText) this.findViewById(R.id.userName);
password = (EditText) this.findViewById(R.id.password);

//set the size
userName.setWidth(editTextSize);
password.setWidth(editTextSize);

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post