2012-05-27 4 views
0

Я хочу, чтобы создать слиток ocntrols, которые соответствуют Повсеместно на всю ширину экрана, поэтому я использовал следующий код:управления не распространяется на ширину экрана

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:background="#d9dee1" 
    > 

    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 

     android:orientation="horizontal" 
      android:background="@drawable/buttonsborder" 

     > 
    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 

     android:orientation="horizontal" 



     > 
     <Button 
      android:id="@+id/Chemo" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Chemo" 
      android:background="@drawable/firstbuttoncolorstyle" 
      android:textColor="@drawable/firstbuttontextstyle" 
      /> 

     <Button 
      android:id="@+id/inpatient" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="inpatient" 
      android:background="@drawable/firstbuttoncolorstyle" 
      android:textColor="@drawable/firstbuttontextstyle" 
      /> 

     <Button 
      android:id="@+id/Mgmt" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Mgmt" 
      android:background="@drawable/firstbuttoncolorstyle" 
      android:textColor="@drawable/firstbuttontextstyle" 
      /> 
      </LinearLayout>  
    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 

     android:orientation="horizontal" 

     > 
     <Button 
      android:id="@+id/PFinder" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="PFinder" 
      android:background="@drawable/secondbuttoncolorstyle" 
      android:textColor="@drawable/secondbuttontextstyle" 
      /> 

     <Button 
      android:id="@+id/Afinder" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Afinder" 
      android:background="@drawable/secondbuttoncolorstyle" 
      android:textColor="@drawable/secondbuttontextstyle" 
      /> 

     <Button 
      android:id="@+id/Calender" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Calender" 
      android:background="@drawable/secondbuttoncolorstyle" 
      android:textColor="@drawable/secondbuttontextstyle" 
      /> 

    </LinearLayout> 

      <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 

     android:orientation="horizontal" 

     > 
      <Button 
      android:id="@+id/Profile" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Profile" 
      android:background="@drawable/thirdbuttoncolorstyle" 
      android:textColor="@drawable/secondbuttontextstyle" 
      /> 

     <Button 
      android:id="@+id/SODEOD" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="SOD/EOD" 
      android:background="@drawable/thirdbuttoncolorstyle" 
      android:textColor="@drawable/secondbuttontextstyle" 
      /> 

     <Button 
      android:id="@+id/Clear" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Clear" 

      android:background="@drawable/thirdbuttoncolorstyle" 
      android:textColor="@drawable/secondbuttontextstyle" 

      /> 

     </LinearLayout> 



        <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 

     android:orientation="horizontal" 

     > 
       <ImageButton 
     android:id="@+id/maillme" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@drawable/mail" /> 


        <ImageButton 
     android:id="@+id/callme" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@drawable/call" /> 

     </LinearLayout> 



    </LinearLayout> 

    <!-- the two columns part --> 

    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="0.80" 
     android:orientation="horizontal" 

     > 

     <LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight=".80" 
      android:id="@+id/submenue" 



      > 

      <!-- this will be the menue list --> 




      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="First Name" /> 


     </LinearLayout> 

     <LinearLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_weight=".20" 
      android:id="@+id/mainLayout" 
      > 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="second Name" /> 
     </LinearLayout> 
    </LinearLayout> 

</LinearLayout> 

, но результат, как в следующем изображение enter image description here

Как распространить элементы управления через ширину экрана (цветные кнопки), и список я создаю на время выполнения кнопки мыши с помощью этого кода

this.inpatient = (Button)this.findViewById(R.id.inpatient); 
    this.inpatient.setOnClickListener(new OnClickListener() { 
     public void onClick(View v) { 

      String[] MainMenue = new String[] { "Chemo Unit", "Inpatient", "Patient tests","Management", "Instructions","Profile","Tools"}; 

      // remove all controls 

      LinearLayout formLayout = (LinearLayout)findViewById(R.id.submenue); 
      formLayout.removeAllViews(); 

      menueview = new ListView(getApplicationContext());    
      menueview.setVisibility(ListView.VISIBLE); 
      LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
        LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); 
      params.gravity = Gravity.RIGHT; 
      menueview.setLayoutParams(params); 


      menueview.setAdapter(new submenueadapter(menueview.getContext(), MainMenue)); 
      formLayout.addView(menueview); 
     } 
    }); 

как увеличить шрифт, а также заполнить высоту

ответ

2

Думаю, у вас есть две возможности. Первый, если вы хотите сохранить свою LinearLayout:
Дайте всем детям вашего подменю layout_width = «match_parent» и установить все его layout_weigth к 1.

Второй способ может быть, чтобы использовать вместо LinearLayout для подменю, это TableLayout:

<TableLayout android:id="@+id/TableLayout" 
    android:layout_height="wrap_content" 
    android:layout_width="match_parent" 
    android:stretchColumns="*"> 

    <!-- Your menu items --> 

    <TableRow android:id="@+id/TableRow" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
    </TableRow> 
</TableLayout> 
+0

можно увеличить размер кнопок немного, и она работала очень хорошо, что о списке, как увеличить его – AMH

+0

Извините, пожалуйста, но у меня есть проблемы, чтобы понять вас. Английский язык тоже не мой родной язык, но, пожалуйста, попробуйте написать более четкие и использовать пунктуации. Какой список вы хотели бы увеличить? –

+0

, как вы можете видеть на изображении в моем вопросе и в коде ниже, я добавляю список динамически, но он настолько мал, что я могу увеличить его размер шрифта и сделать каждый элемент ist более крупным. это мой первый вопрос. мой второй я могу увеличить размер кнопки (я имею в виду высоту) – AMH