我发现,无论是fill_parent和match_parent意味着同样的事情
我发现的唯一区别fill_parent是从API级别8开始被弃用并被替换为match_parent
但是,我没有注意到这两者之间有任何区别.如果两者都相同,那么为什么会被fill_parent弃用.任何人都可以解释这两者之间的任何差异,除了一个被弃用而另一个不被弃用的事实?
我已经浏览了http://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html
我在sqllite中有一些数据,每次都会更新,我点击保存按钮,我想将数据显示到表格布局中,以便为更新的数据添加更多行.
我有一些代码,但它只显示更新以前数据的更新数据,我希望在更新数据时添加更多行.
我知道这只是在表格布局中添加一行但是如何添加更多行?
TableLayout tl=(TableLayout)findViewById(R.id.maintable);
TableRow tr1 = new TableRow(this);
tr1.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
TextView textview = new TextView(this);
textview.setText(data);
//textview.getTextColors(R.color.)
textview.setTextColor(Color.YELLOW);
tr1.addView(textview);
tl.addView(tr1, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
Run Code Online (Sandbox Code Playgroud) 我需要使用视频作为我的背景.首先,我将视频文件放在drawable文件夹中,并LinearLayout在main.xml中作为后台调用.但在运行应用程序时,我只看到了黑屏.然后我尝试使用VideoView并调用它如下:
<VideoView
android:id="@+id/video"
android:layout_width="320px"
android:layout_height="240px"
android:layout_gravity="center"
android:background="@raw/hp"/>
Run Code Online (Sandbox Code Playgroud)
在我的活动文件中,我使用以下代码片段调用它:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView video=(VideoView) findViewById(R.id.video);
video.start();
}
Run Code Online (Sandbox Code Playgroud)
但我仍然没有收到视频文件.我的主要建议是使用气泡视频作为背景,并在其上放置两个气泡按钮,让用户感觉像水景屏幕.谁能帮我?
我想从res文件夹中使用的视频文件.不是来自SD卡或任何外部媒体文件夹.
这是我的布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:layout_marginLeft="5dip" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textColor="#ffffff" >
</TextView>
</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/nazajGumb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/roaming_backbtn" >
</Button>
<Button
android:id="@+id/homeBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="@string/roaming_homebtn" >
</Button>
</LinearLayout>
<Spinner
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dip"
android:prompt="@string/roaming_spinnerPrompt" />
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Random text"
android:textColor="#ffffcc" />
<Button
android:id="@+id/testBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="test" >
</Button>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
LinearLayout2中的ImageView和TextView的位置以及LinearLayout3中按钮的positiong不起作用(使用布局重力). …
现在我在我的应用程序中使用MATCH_PARENT.我决定让Android 2.1用户使用该应用程序,但在Android 2.2之前不会引入MATCH_PARENT
如果我希望我的应用在Android版本为2.2及以上时使用MATCH_PARENT,但是如果它是2.1(或者如果我决定稍后打开它则更低),我应该如何使用FILL_PARENT?
我认为fill_parent有很大的价值,我想自己实现它,所以我可以做的不仅仅是填充剩余的空间(例如:填充80%的剩余空间等)
fill_parent实际上如何在引擎盖下工作?如何计算剩余空间,它如何在运行时工作等.
我在过去做过类似的事情,fill_parent根据当前的屏幕大小,元素应该占用的屏幕大小等来计算元素应该占用的空间等等.但我想知道Android是如何做到的与fill_parent.
可能重复:
android FILL_PARENT和MATCH_PARENT中match_parent和fill_parent属性的区别是什么
我已经通过android开发者网站,他们给出以下差异:
注意:从Android 2.2(API级别8)开始,"fill_parent"已重命名为"match_parent"以更好地反映行为.原因是如果将视图设置为"fill_parent",则在考虑兄弟视图后,它不会展开以填充剩余空间,而是扩展以匹配父视图的大小,无论它与任何兄弟视图重叠.
但任何人都可以用例子解释.所以事情可能会清楚.
android ×7