我尝试了很多东西,但没有得到任何解决方案,我在运行时设置文本,我需要弹出的宽度根据文本大小LinearLayout viewGroup =(LinearLayout)((Activity)context).findViewById(R.id.popup);
LayoutInflater layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = layoutInflater.inflate(R.layout.popup_layout, viewGroup);
title_tv = (TextView) layout.findViewById(R.id.popup_txt);
title_tv.setText(title_P);
PopupWindow popup = new PopupWindow(context);
final float SCALE = layout.getResources().getDisplayMetrics().density;
int mode = MeasureSpec.getMode(View.MeasureSpec.UNSPECIFIED);
int measuredWidth = MeasureSpec.getSize(View.MeasureSpec.UNSPECIFIED);
popup.setWidth(measuredWidth);
popup.setHeight(60);
popup.setContentView(layout);
//popup.setWindowLayoutMode();
popup.setFocusable(true);
Run Code Online (Sandbox Code Playgroud) 我有以下布局与imageview和textfield,
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="26dp"
android:layout_marginTop="22dp"
android:src="@drawable/a01" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/imageView1"
android:layout_marginTop="31dp"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这个布局是透明的,我想在特定活动的基础上调用此布局,当特定活动首次启动时,如何实现它addview()?
我在界面构建器中使用类大小,为不同的大小定义略有不同的设计.
我没有为特定尺寸安装我的一个视图.这按预期工作,但现在我想以编程方式能够判断是否安装了该视图.无论是否安装,看起来视图永远不会是零,我看不到任何isInstalled标志来检查.
这样做的正确方法是什么?
我正在为Android应用程序设计一个布局.这是布局的骨架.

我尝试的是使用表格布局,因为GUI可以分成表格行和列.基本上,我想把布局分成两列,如你所见.这是xml代码
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<!-- 2 columns -->
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dip" >
<View
android:id="@+id/view1"
android:layout_weight="7"
android:layout_width="0dp"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView1"
android:text="Column 1"
android:textAppearance="?android:attr/textAppearanceLarge" />
</View>
<View
android:id="@+id/view2"
android:layout_weight="3"
android:layout_width="0dp"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button1"
android:text="Column 2" />
</View>
</TableRow>
</TableLayout>
Run Code Online (Sandbox Code Playgroud)
我在GUI中遇到以下错误
Exception raised during rendering: android.view.View cannot be cast to android.view.ViewGroup
Run Code Online (Sandbox Code Playgroud)
我认为这表示我们无法对观点进行分组.如果不可能,该如何处理.我来自网络背景.我以为我可以将视图用作html中的div.
我有一个扩展SurfaceView的自定义视图.我正在画布上画一个图像.当用户触摸画布上的某个点时,我想要显示触摸坐标周围区域的放大视图.并且优选地,当手指移动时,我想相应地更新放大视图的内容.
我想知道android平台本机是否支持这样的功能.如果没有,你们中的一个人能否指出一个很好的例子,可以让我开始或分享如何实现它的想法.我没有做太多这种2D或3D图形,我仍然试图理解Canvas和Matrix类来看看我可以使用什么.
我在论坛上搜索了一个类似的问题,但找不到任何问题.所以,请不要标记我提出已经存在的问题.
不 - 我没有使用OpenGL-ES或任何此类第三方库(尚未).
谢谢大家.
android ×4
autolayout ×1
ios ×1
popup ×1
popupwindow ×1
size-classes ×1
xcode ×1
xcode6 ×1
zoom ×1