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;
}
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);
}
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));
}
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));
}
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);
}
Aggregations