Search in sources :

Example 46 with LinearLayout

use of android.widget.LinearLayout in project platform_frameworks_base by android.

the class ListItemFactory method twoButtonsSeparatedByFiller.

/**
     * Create a view with a button at the top and bottom, with filler in between.
     * The filler is sized to take up any space left over within desiredHeight.
     *
     * @param position      The position within the list.
     * @param context       The context.
     * @param desiredHeight The desired height of the entire view.
     * @return The created view.
     */
public static View twoButtonsSeparatedByFiller(int position, Context context, int desiredHeight) {
    if (desiredHeight < 90) {
        throw new IllegalArgumentException("need at least 90 pixels of height " + "to create the two buttons and leave 10 pixels for the filler");
    }
    final LinearLayout ll = new LinearLayout(context);
    ll.setOrientation(LinearLayout.VERTICAL);
    final LinearLayout.LayoutParams buttonLp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 50);
    final Button topButton = new Button(context);
    topButton.setLayoutParams(buttonLp);
    topButton.setText("top (position " + position + ")");
    ll.addView(topButton);
    final TextView middleFiller = new TextView(context);
    middleFiller.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, desiredHeight - 100));
    middleFiller.setText("filler");
    ll.addView(middleFiller);
    final Button bottomButton = new Button(context);
    bottomButton.setLayoutParams(buttonLp);
    bottomButton.setText("bottom (position " + position + ")");
    ll.addView(bottomButton);
    ll.setTag("twoButtons");
    return ll;
}
Also used : Button(android.widget.Button) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 47 with LinearLayout

use of android.widget.LinearLayout in project platform_frameworks_base by android.

the class BigCache method onCreate.

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    final LinearLayout testBed = new LinearLayout(this);
    testBed.setOrientation(LinearLayout.VERTICAL);
    testBed.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    final int cacheSize = ViewConfiguration.getMaximumDrawingCacheSize();
    final Display display = getWindowManager().getDefaultDisplay();
    final int screenWidth = display.getWidth();
    final int screenHeight = display.getHeight();
    final View tiny = new View(this);
    tiny.setId(R.id.a);
    tiny.setBackgroundColor(0xFFFF0000);
    tiny.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, screenHeight));
    final View large = new View(this);
    large.setId(R.id.b);
    large.setBackgroundColor(0xFF00FF00);
    // Compute the height of the view assuming a cache size based on ARGB8888
    final int height = 2 * (cacheSize / 2) / screenWidth;
    large.setLayoutParams(new LinearLayout.LayoutParams(screenWidth, height));
    final ScrollView scroller = new ScrollView(this);
    scroller.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    testBed.addView(tiny);
    testBed.addView(large);
    scroller.addView(testBed);
    setContentView(scroller);
}
Also used : ScrollView(android.widget.ScrollView) ViewGroup(android.view.ViewGroup) ScrollView(android.widget.ScrollView) View(android.view.View) LinearLayout(android.widget.LinearLayout) Display(android.view.Display)

Example 48 with LinearLayout

use of android.widget.LinearLayout in project platform_frameworks_base by android.

the class CreateViewTest method testLayout5.

@SmallTest
public void testLayout5() throws Exception {
    TextView text = new TextView(mContext);
    text.setText("S");
    LinearLayout vert = new LinearLayout(mContext);
    vert.addView(text, new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT, 0));
}
Also used : TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 49 with LinearLayout

use of android.widget.LinearLayout in project platform_frameworks_base by android.

the class CreateViewTest method testLayout3.

@SmallTest
public void testLayout3() throws Exception {
    LinearLayout vert = new LinearLayout(mContext);
    ViewOne one = new ViewOne(mContext);
    vert.addView(one, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0));
    ViewOne two = new ViewOne(mContext);
    vert.addView(two, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0));
    ViewOne three = new ViewOne(mContext);
    vert.addView(three, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0));
    ViewOne four = new ViewOne(mContext);
    vert.addView(four, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0));
    ViewOne five = new ViewOne(mContext);
    vert.addView(five, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0));
    ViewOne six = new ViewOne(mContext);
    vert.addView(six, new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 0));
}
Also used : LinearLayout(android.widget.LinearLayout) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 50 with LinearLayout

use of android.widget.LinearLayout in project platform_frameworks_base by android.

the class Merge method onCreate.

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    mLayout = new LinearLayout(this);
    mLayout.setOrientation(LinearLayout.VERTICAL);
    LayoutInflater.from(this).inflate(R.layout.merge_tag, mLayout);
    setContentView(mLayout);
}
Also used : LinearLayout(android.widget.LinearLayout)

Aggregations

LinearLayout (android.widget.LinearLayout)1205 View (android.view.View)473 TextView (android.widget.TextView)455 ViewGroup (android.view.ViewGroup)203 ImageView (android.widget.ImageView)196 Button (android.widget.Button)167 ScrollView (android.widget.ScrollView)125 ListView (android.widget.ListView)100 LayoutInflater (android.view.LayoutInflater)90 FrameLayout (android.widget.FrameLayout)85 Context (android.content.Context)80 AdapterView (android.widget.AdapterView)74 EditText (android.widget.EditText)74 Intent (android.content.Intent)66 AbsListView (android.widget.AbsListView)58 LayoutParams (android.widget.LinearLayout.LayoutParams)48 RelativeLayout (android.widget.RelativeLayout)48 Bitmap (android.graphics.Bitmap)46 OnClickListener (android.view.View.OnClickListener)44 Drawable (android.graphics.drawable.Drawable)42