xml:
<?xml version="1.0" encoding="utf-8" ?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rowCount="10"
android:columnCount="4"
android:id="@+id/mainwindow"
> <TextView
android:id="@+id/show"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:singleLine="false"
android:textSize="50sp"
android:layout_gravity="right"
android:background="#000"
android:textColor="@color/red"
android:gravity="right"
/>
</TableLayout>java:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.calculator); tableLayout = (TableLayout) findViewById(R.id.mainwindow);
text = (TextView) findViewById(R.id.show);
text.setMovementMethod(ScrollingMovementMethod.getInstance());
text.setLines(2);
Button[] bn = new Button[20]; tableLayout.setStretchAllColumns(true);
tableLayout.setShrinkAllColumns(true); int n = 0;
for (int i = 0; i < 5; i++) {
TableRow textrow = new TableRow(this);
for (int j = 0; j < 4; j++) {
bn[n] = new Button(this);
bn[n].setText(chars[n]);
bn[n].setTextSize(30);
TableRow.LayoutParams lp = new TableRow.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
textrow.addView(bn[n], lp);
n++;
}
tableLayout.addView(textrow);
}
}请问下如何让android程序自动适应各种屏幕大小,这个程序在虚拟机上可以自动适应屏幕大小,但是一安装到手机上面就不能自动适应屏幕大小
<?xml version="1.0" encoding="utf-8" ?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rowCount="10"
android:columnCount="4"
android:id="@+id/mainwindow"
> <TextView
android:id="@+id/show"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:singleLine="false"
android:textSize="50sp"
android:layout_gravity="right"
android:background="#000"
android:textColor="@color/red"
android:gravity="right"
/>
</TableLayout>java:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.calculator); tableLayout = (TableLayout) findViewById(R.id.mainwindow);
text = (TextView) findViewById(R.id.show);
text.setMovementMethod(ScrollingMovementMethod.getInstance());
text.setLines(2);
Button[] bn = new Button[20]; tableLayout.setStretchAllColumns(true);
tableLayout.setShrinkAllColumns(true); int n = 0;
for (int i = 0; i < 5; i++) {
TableRow textrow = new TableRow(this);
for (int j = 0; j < 4; j++) {
bn[n] = new Button(this);
bn[n].setText(chars[n]);
bn[n].setTextSize(30);
TableRow.LayoutParams lp = new TableRow.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
textrow.addView(bn[n], lp);
n++;
}
tableLayout.addView(textrow);
}
}请问下如何让android程序自动适应各种屏幕大小,这个程序在虚拟机上可以自动适应屏幕大小,但是一安装到手机上面就不能自动适应屏幕大小
解决方案 »
- 急 急 急!关于FragmentPagerAdapter 滑动的问题
- 如何在主类中添加外部定义的view——小白,期待高手解答,进来聊聊经验也感激不尽啊——————-——————
- 请问ANDROID怎么突破24M的堆内存限制
- 读取android系统中apk的大小
- 安装之后直接点击open后重复创建activity的问题
- 播放rtsp流媒体的几个问题
- android studio 配置问题
- java有没有拷贝构造函数以及操作符重载.
- 删除listview其中一个列表项,下面的列表项向上移动的效果要怎么实现??
- android 如何获取真机屏幕指定坐标颜色值
- android 模拟器上的程序移到真机上,出现应用程序意外停止,请重试
- androidsocket通信传送对象流异常。
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
这句改成:
TableRow.LayoutParams lp = new TableRow.LayoutParams(
0, LayoutParams.WRAP_CONTENT, 1);
楼主试试
高度也是一样