我有两个相对布局.两者都具有填充父级的宽度和100个倾角的高度.我的要求是,当我点击第一个布局时,它应缩小到50dip高度,另一个扩展到150dip高度.这样做我得到了例外.请帮我如何在运行时更改布局宽度和高度.
final LinearLayout RLChange = new LinearLayout(this);
RLChange.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
RLChange.setOrientation(LinearLayout.VERTICAL);
final LinearLayout RLGreen = new LinearLayout(this);
RLGreen.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
300));
RLGreen.setBackgroundColor(Color.GREEN);
RLGreen.setOrientation(LinearLayout.HORIZONTAL);
Button btnClick = new Button(this);
btnClick.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
btnClick.setBackgroundColor(Color.RED);
RLGreen.addView(btnClick);
final LinearLayout RLYellow = new LinearLayout(this);
RLYellow.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
200));
RLYellow.setBackgroundColor(Color.YELLOW);
btnClick.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Toast.makeText(getApplicationContext(), "click", Toast.LENGTH_SHORT).show();
RLGreen.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
}
});
RLChange.addView(RLGreen);
RLChange.addView(RLYellow);
setContentView(RLChange);
Log Cat
03-10 11:01:35.328: INFO/NotificationService(574): enqueueToast pkg=Changewidth.com callback=android.app.ITransientNotification$Stub$Proxy@43948648 duration=0
03-10 11:01:35.388: DEBUG/AndroidRuntime(1505): Shutting down VM
03-10 11:01:35.388: WARN/dalvikvm(1505): threadid=3: …Run Code Online (Sandbox Code Playgroud) 现在这是我的布局XML代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:id="@+id/RelativeLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/default1"
android:id="@+id/default1"
android:layout_gravity="center"
android:scaleType="fitXY">
</ImageView>
<ImageView
android:layout_marginTop="19dp"
android:layout_width="180dp"
android:layout_height="45dp"
android:src="@drawable/fc_postyour_best_score_bg"
android:id="@+id/postscore"
android:layout_alignParentRight="true"
android:scaleType="fitXY">
</ImageView>
<ImageButton
android:layout_marginTop="22dp"
android:layout_width="35dp"
android:layout_height="35dp"
android:background="@drawable/fctwitterup"
android:layout_marginLeft="7dp"
android:id="@+id/twitter"
android:layout_alignRight="@id/postscore"
android:scaleType="fitXY">
</ImageButton>
<ImageButton
android:layout_marginTop="22dp"
android:layout_width="35dp"
android:layout_height="35dp"
android:background="@drawable/fcfacebookdown"
android:id="@+id/fb"
android:layout_toLeftOf="@id/twitter">
</ImageButton>
<ImageButton
android:layout_width="160dp"
android:layout_height="40dp"
android:background="@drawable/fsremove_ads_down"
android:id="@+id/fsremove_ads_down"
android:layout_below="@id/postscore"
android:layout_alignParentRight="true"
android:layout_marginBottom="3dp">
</ImageButton>
<ToggleButton
android:id="@+id/fsvibrate_on"
android:layout_width="135dip"
android:layout_height="35dip"
android:textOff=""
android:textOn=""
android:layout_below="@+id/fsremove_ads_down"
android:layout_alignParentRight="true"
android:background="@drawable/fsvibrate_on">
</ToggleButton>
<ImageButton
android:layout_width="210dp"
android:layout_height="60dp"
android:background="@drawable/fcplaydown"
android:id="@+id/fcplaydown"
android:layout_centerInParent="true">
</ImageButton>
<ToggleButton
android:id="@+id/fcsoundondown"
android:layout_width="35dp"
android:layout_height="35dp"
android:textOff=""
android:textOn="" …Run Code Online (Sandbox Code Playgroud) 我在Unity3d中使用Windows Phone 8中的Sqlite数据库时遇到了一些问题.如果我们使用sqlite Database,则不允许在Windows Phone 8中构建项目.因为问题是在Windows Phone 8版本中使用System.Data.dll.这个DLL在其他版本(Android,IOS)中运行完美.我也尝试了不同的dll,如Microsoft的System.Data.dll,.Net 3.5和4.0 Framework System.Data.dll,Mono的System.Data.dll,但这些都没有用.
在Unity3d中有没有人在WP8中使用sqlite数据库?如果没有,那么我们如何在Unity3d中使用WP8中的数据库?
现在我有一个ImgeView,它有一个圆圈,我想找到那个圆圈的中心点,所以我尝试了下面的代码,但似乎没有工作
int[] location = new int[2];
imageView.getLocationOnScreen(location);
int radius=imageView.getHeight()/2;
int[] center=new int[2];
center[0]=location[0]+radius;
center[1]=location[1]+radius;
Run Code Online (Sandbox Code Playgroud)
所以我通过"位置"得到的坐标是图像视图的顶点还是没有?
请帮我看看如何获得imageview的中心点.