Я использую Android Studio 3.5.3 и имею приложение с действиями с изображениями и кнопкой. У меня есть линейный макет в представлении прокрутки. Я хочу иметь возможность увеличить масштаб всей активности, когда она работает на устройстве android. Как бы вы go об этом? Я провел немало поисков в Интернете и не нашел решения, которое работает.
Это файл java из стандартной операции, которую я использую:
package compositions.david.compositions;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ScrollView;
public class MajorQPP extends AppCompatActivity{
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_major_qpp);
}
public void goToDB(View view){
ScrollView sv=(ScrollView)findViewById(R.id.scrl1);
sv.scrollTo(0,1550);
}
public void goToDN(View view){
ScrollView sv=(ScrollView)findViewById(R.id.scrl1);
sv.scrollTo(0,1855);
}
public void goToG(View view){
ScrollView sv=(ScrollView)findViewById(R.id.scrl1);
sv.scrollTo(0,3550);
}
public void goToGr(View view){
ScrollView sv=(ScrollView)findViewById(R.id.scrl1);
sv.scrollTo(0,3920);
}
public void goToLB(View view){
ScrollView sv=(ScrollView)findViewById(R.id.scrl1);
sv.scrollTo(0,6010);
}
public void goToPB(View view){
ScrollView sv=(ScrollView)findViewById(R.id.scrl1);
sv.scrollTo(0,7880);
}
}
Это соответствующий xml файл:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:context=".MajorQPP">
<ScrollView
android:id="@+id/scrl1"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/Doubles_Peal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/p8"
android:textColor="@android:color/black"
android:textSize="18dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="@+id/Doubles_Peal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="To see compositions for a specific method or group of methods click the relevant button"
android:textColor="@android:color/black"
android:textSize="17dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<Button
android:id="@+id/button1"
android:layout_width="272dp"
android:layout_height="wrap_content"
android:onClick="goToDB"
android:text="Double Bob" />
<Button
android:id="@+id/button2"
android:layout_width="272dp"
android:layout_height="wrap_content"
android:onClick="goToDN"
android:text="Double Norwich" />
<Button
android:id="@+id/button3"
android:layout_width="272dp"
android:layout_height="wrap_content"
android:onClick="goToG"
android:text="Gainsborough" />
<Button
android:id="@+id/button4"
android:layout_width="272dp"
android:layout_height="wrap_content"
android:onClick="goToGr"
android:text="Grandsire" />
<Button
android:id="@+id/button5"
android:layout_width="272dp"
android:layout_height="wrap_content"
android:onClick="goToLB"
android:text="Little Bob" />
<Button
android:id="@+id/button6"
android:layout_width="272dp"
android:layout_height="wrap_content"
android:onClick="goToPB"
android:text="Plain Bob" />
<TextView
android:id="@+id/Doubles_Peal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
android:textColor="@android:color/black"
android:textSize="17dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<ImageView
android:id="@+id/imageView1"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/db1" />
<ImageView
android:id="@+id/imageView2"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/dn1" />
<ImageView
android:id="@+id/imageView3"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/dn2" />
<ImageView
android:id="@+id/imageView4"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/g1" />
<ImageView
android:id="@+id/imageView5"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/g81" />
<ImageView
android:id="@+id/imageView6"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/g82" />
<ImageView
android:id="@+id/imageView7"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/lb8qp1" />
<ImageView
android:id="@+id/imageView8"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/lb8qp2" />
<ImageView
android:id="@+id/imageView9"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/lb8qp3" />
<ImageView
android:id="@+id/imageView10"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/pb8qp1" />
<ImageView
android:id="@+id/imageView11"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/pb8qp2" />
<ImageView
android:id="@+id/imageView12"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/pb8qp3" />
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>