我正在制作一个代码,根据其应用程序提供的屏幕大小来改变其大小.它通过View的onSizeChanged()和onDraw()方法获取整个宽度和高度(或其适当的视图的w和h).
它在另一个代码中工作得很好但是现在每当我尝试输入命令'setLayoutParams()时它都显示错误消息你能帮我解决这个问题吗?setLayoutParams()实际上在代码中的任何地方都不起作用.下面是主类代码.
public class ManipulateDesign extends Activity { private LinearLayout ll; private ScrollView sv; private TextView tv; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ll = (LinearLayout) findViewById(R.id.ll); sv = (ScrollView) findViewById(R.id.sv); tv = new TextView(this); tv.setText("You're in the first ScrollView\n" + "- Living Universe \n" + "Wish (upon a star) Hope to (be again)\n" + "The one you find, when all is done and through!\n" + "If all, made …
我的情况是:我曾经做过一个android项目(2.2版本)但很快就需要格式化我的电脑.格式化后,我再次下载了eclipse,但是当我导入项目时,我无法使用xml的"图形布局"菜单.它没有向我显示如下图所示的内容.
http://img525.imageshack.us/img525/3586/19978552.png
我清理了项目并更新了Android SDK,但是,这些似乎都没有.可能是什么导致了这个?
你好Android程序员,
我试图制作一个带有Framelayout的EditText和底部按钮栏的屏幕,这样无论用户编辑文本有多大,我的底部按钮栏都会保留在底部,因为FrameLayout使我的底部按钮栏位于顶部的屏幕.以下是我的代码.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<EditText android:id="@+id/tm_et_date_year" android:layout_width="120px" android:layout_height="wrap_content"/>
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/tm_ll_buttons" android:orientation="horizontal"
android:gravity="bottom">
<Button android:id="@+id/tm_btn_save" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Save" android:layout_weight="1" />
<Button android:id="@+id/tm_btn_cancel" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Cancel" android:layout_weight="1" />
</LinearLayout>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
然而,当我完成编码时,底部按钮栏突然出现在TOP而不是BOTTOM,如下所示.
http://img269.imageshack.us/img269/6374/71485552.jpg
我搜索了这个问题,但找不到任何可以帮助我的好文章,所以现在请教你.如果有人知道如何解决这个问题,你能帮助我吗?
谢谢阅读