我试图通过激化布局,以图谋划策。
View marker = ((LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.overlay_view, null);
Now i want to convert this View to a Bitmap:
public static Bitmap createDrawableFromView(Context context, View view){
DisplayMetrics displayMetrics = new DisplayMetrics();
((Activity)context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
view.measure(displayMetrics.widthPixels, displayMetrics.heightPixels);
view.layout(0, 0, displayMetrics.widthPixels, displayMetrics.heightPixels);
Bitmap cache = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(cache);
view.draw(canvas);
return cache;
}
I also tried measure(1, 1) and layout(0 ,0 ,0 ,0) without any changes. The Bitmap looks like the filled layout. Now the Problem: If i put something into the View thats makes the View bigger than the Displaysize in width or height (example: a TextView with a long text), the Bitmap is also bigger. The Views XML width and height is WRAP_CONTENT but it didnt works. I never put this View somewhere to display it (becouse i only need the Bitmap).
问题:怎样才能将妇女权利行动纳入到最高范围:显示Width?
我尝试了意见。 我真心要理解所发生的事情,那是孤立布局,确定观点的内容。
这一观点:正如我所显示的那样,我们总是会更大吗? (如果在其中增加部分)
这里是《拉伊特》的一个实例:
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/somedrawable"
android:padding="10dp"
android:clickable="true">
<TextView android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"/>
<TextView android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/name"
android:text="Description"
android:textSize="20dp"
android:textColor="#ffffff"/>
</RelativeLayout>