Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <LinearLayout
- android:id="@+id/A"
- android:layout_height="fill_parent"
- android:layout_width="fill_parent"
- android:weightSum="8.0"
- android:orientation="vertical">
- <LinearLayout
- android:id="@+id/B"
- android:layout_height="0dip"
- android:layout_width="fill_parent"
- android:layout_weight="1.0"/>
- <LinearLayout
- android:id="@+id/C"
- android:layout_height="0dip"
- android:layout_width="fill_parent"
- android:layout_weight="3.0"
- </LinearLayout>
- Context context;
- @Override
- public void onAttach(Activity activity){
- super.onAttach(activity);
- context = activity;
- }
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- Display display = ((WindowManager)
- context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
- DisplayMetrics metrics = new DisplayMetrics();
- display.getMetrics(metrics);
- float pixHeight = metrics.heightPixels;
- float pixWidth = metrics.widthPixels;
- float density = context.getResources().getDisplayMetrics().density;
- float dpHeight = pixHeight / density;
- float dpWidth = pixWidth / density;
- // make various layouts using your measurements, send the
- // measure of each parent to each custom drawn child, or
- // send the bounds of each child as determined by the size of each parent
- return someView;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement