Deprecate fill_parent and introduce match_parent.

Bug: #2361749.
This commit is contained in:
Romain Guy
2010-01-08 15:05:33 -08:00
parent b4e39aebf6
commit 74192eafec
243 changed files with 1003 additions and 1015 deletions

View File

@@ -28,7 +28,6 @@ import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.LinearLayout.LayoutParams;
/**
@@ -63,11 +62,11 @@ public class LaunchingPreferences extends Activity implements OnClickListener {
Button launchPreferences = new Button(this);
launchPreferences.setText(getString(R.string.launch_preference_activity));
launchPreferences.setOnClickListener(this);
layout.addView(launchPreferences, new LayoutParams(LayoutParams.FILL_PARENT,
layout.addView(launchPreferences, new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
mCounterText = new TextView(this);
layout.addView(mCounterText, new LayoutParams(LayoutParams.FILL_PARENT,
layout.addView(mCounterText, new LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
updateCounterText();

View File

@@ -19,14 +19,11 @@ package com.example.android.apis.app;
import com.example.android.apis.R;
import android.app.Activity;
import android.app.NotificationManager;
import android.content.Context;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
@@ -93,7 +90,7 @@ public class MenuInflateFromXml extends Activity {
// Add the spinner
layout.addView(mSpinner,
new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
// Create help text
@@ -103,7 +100,7 @@ public class MenuInflateFromXml extends Activity {
// Add the help, make it look decent
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(10, 10, 10, 10);
layout.addView(mInstructionsText, lp);

View File

@@ -21,7 +21,6 @@ package com.example.android.apis.graphics;
import com.example.android.apis.R;
import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
import android.graphics.BitmapFactory;
import android.graphics.Bitmap;
@@ -34,8 +33,6 @@ import android.widget.ScrollView;
import android.view.LayoutInflater;
import android.view.View;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.util.DisplayMetrics;
import android.util.Log;
@@ -117,20 +114,20 @@ public class DensityActivity extends Activity {
private View scrollWrap(View view) {
ScrollView scroller = new ScrollView(this);
scroller.addView(view, new ScrollView.LayoutParams(ScrollView.LayoutParams.FILL_PARENT,
ScrollView.LayoutParams.FILL_PARENT));
scroller.addView(view, new ScrollView.LayoutParams(ScrollView.LayoutParams.MATCH_PARENT,
ScrollView.LayoutParams.MATCH_PARENT));
return scroller;
}
private void addLabelToRoot(LinearLayout root, String text) {
TextView label = new TextView(this);
label.setText(text);
root.addView(label, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
root.addView(label, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
}
private void addChildToRoot(LinearLayout root, LinearLayout layout) {
root.addView(layout, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
root.addView(layout, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
}

View File

@@ -76,7 +76,7 @@ public class PictureLayout extends ViewGroup {
@Override
protected LayoutParams generateDefaultLayoutParams() {
return new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
return new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
}
@Override

View File

@@ -24,7 +24,6 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.ViewGroup.MarginLayoutParams;
import android.widget.AbsListView;
import android.widget.BaseExpandableListAdapter;
import android.widget.ExpandableListAdapter;
@@ -112,7 +111,7 @@ public class ExpandableList1 extends ExpandableListActivity {
public TextView getGenericView() {
// Layout parameters for the ExpandableListView
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, 64);
ViewGroup.LayoutParams.MATCH_PARENT, 64);
TextView textView = new TextView(ExpandableList1.this);
textView.setLayoutParams(lp);

View File

@@ -67,8 +67,8 @@ public class ImageSwitcher1 extends Activity implements
ImageView i = new ImageView(this);
i.setBackgroundColor(0xFF000000);
i.setScaleType(ImageView.ScaleType.FIT_CENTER);
i.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
i.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT));
return i;
}

View File

@@ -46,11 +46,11 @@ public class InternalSelectionFocus extends Activity {
final LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.HORIZONTAL);
layout.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT));
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,
ViewGroup.LayoutParams.FILL_PARENT, 1);
ViewGroup.LayoutParams.MATCH_PARENT, 1);
final InternalSelectionView leftColumn = new InternalSelectionView(this, 5, "left column");
leftColumn.setLayoutParams(params);

View File

@@ -44,7 +44,7 @@ public class InternalSelectionScroll extends Activity {
ScrollView sv = new ScrollView(this);
ViewGroup.LayoutParams svLp = new ScrollView.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
LinearLayout ll = new LinearLayout(this);
@@ -54,7 +54,7 @@ public class InternalSelectionScroll extends Activity {
InternalSelectionView isv = new InternalSelectionView(this, 10);
int screenHeight = getWindowManager().getDefaultDisplay().getHeight();
LinearLayout.LayoutParams llLp = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
2 * screenHeight); // 2x screen height to ensure scrolling
isv.setLayoutParams(llLp);
ll.addView(isv);

View File

@@ -25,7 +25,7 @@ import android.os.Bundle;
/**
* Demonstrates using fill_parent within a linear layout whose size is not fixed.
* Demonstrates using match_parent within a linear layout whose size is not fixed.
*
*/
public class LinearLayout7 extends Activity {

View File

@@ -346,12 +346,12 @@ public class List4 extends ListActivity {
mTitle = new TextView(context);
mTitle.setText(title);
addView(mTitle, new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
mDialogue = new TextView(context);
mDialogue.setText(words);
addView(mDialogue, new LinearLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
}
/**

View File

@@ -374,11 +374,11 @@ public class List6 extends ListActivity
mTitle = new TextView(context);
mTitle.setText(title);
addView(mTitle, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
addView(mTitle, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
mDialogue = new TextView(context);
mDialogue.setText(dialogue);
addView(mDialogue, new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
addView(mDialogue, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
mDialogue.setVisibility(expanded ? VISIBLE : GONE);
}

View File

@@ -20,7 +20,6 @@ import com.example.android.apis.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Button;
@@ -41,7 +40,7 @@ public class ScrollView2 extends Activity {
TextView textView = new TextView(this);
textView.setText("Text View " + i);
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT
);
layout.addView(textView, p);

View File

@@ -13,7 +13,7 @@
<dd>Demonstrates a simple LinearLayout, with child width set to WRAP_CONTENT. </dd>
<dt><a href="LinearLayout2.html">2. Vertical (Fill Screen)</a></dt>
<dd>Demonstrates a simple LinearLayout, with child width set to FILL_PARENT.</dd>
<dd>Demonstrates a simple LinearLayout, with child width set to MATCH_PARENT.</dd>
<dt><a href="LinearLayout3.html">3. Vertical (Padded)</a></dt>
<dd>Demonstrates a LinearLayout where one of the elements can expand to fill any remaining screen space (weight=1). </dd>
@@ -25,7 +25,7 @@
<dd>Demonstrates nested layouts to create a user form.</dd>
<dt><a href="LinearLayout6.html">6. Uniform Size</a></dt>
<dd>LinearLayout which uses a combination of wrap_content on itself and fill_parent on its children to get every item to be the same width.</dd>
<dd>LinearLayout which uses a combination of wrap_content on itself and match_parent on its children to get every item to be the same width.</dd>
<dt><a href="LinearLayout7.html">7. Fill Parent</a></dt>
<dd>Demonstrates a horizontal linear layout with equally sized columns. Some columns force their height to match the parent.</dd>