English 中文(简体)
控制控制不通过屏幕宽度扩散
原标题:the controls not spread through the width of screen

我想创建能穿透整个屏幕宽度的阴极分子栏, 所以我用了以下代码:

<?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>

but the result is as in the following image 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);
        }
    });

如何增加字体和填充高度

问题回答

I think you have two possibilities. The first one if you want to keep your LinearLayout:
Give all the children of your sub menu layout_width="match_parent" and set all its layout_weigth to 1.

第二种方法可能是,使用线性拉尤特而不是使用线性拉尤特作为子菜单,这个表格拉尤特:

<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>




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签