View.setScaleX()
メソッドとView.setScaleY()
メソッドを使用してview
サイズを小さくした後、結果には既に表示されているコンテンツのみが表示され、ズームインしたときに画面に収まらなかった残りの部分は除外されます。残りの部分を強制的に表示するにはどうすればよいですかコンテンツ?
XML: activity_main.xml
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/table"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
JAVA: MainActivity.java
package com.example.zoom;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.LinearLayout;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TableLayout table = (TableLayout) findViewById(R.id.table);
int textViewSize = 100;
int tableColCount = 15;
int tableRowCount = 15;
for (int row = 0; row < tableRowCount; row++) {
TableRow tr = new TableRow(this);
for (int col = 0; col < tableColCount; col++) {
TextView textView = new TextView(this);
textView.setText("" + row + "." + col);
textView.setTextSize(20.0f);
tr.addView(textView, textViewSize, textViewSize);
} // for
table.addView(tr);
} // for
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
LinearLayout table = (LinearLayout) findViewById(R.id.table);
switch (item.getItemId()) {
case R.id.action_zoom_in:
table.setScaleX(1.0f);
table.setScaleY(1.0f);
break;
case R.id.action_zoom_out:
table.setScaleX(0.25f);
table.setScaleY(0.25f);
break;
} // switch
return true;
}
}
この質問は私の質問とほとんど同じであることに気付きましたが、コードも回答もありませんでした。