线性布局网格在模拟器中显示但在设备上不显示,可能是什么原因?
Linear Layout grid showing in emulator but not on device, what could be cause?
我目前 运行 activity 在模拟器 (Nexus 5X API 27) 上运行良好,但是在设备 (Samsung S8 Plus) 上执行它时;线性布局网格不会出现。我已经添加了适当的约束,但它们仍然没有显示。
尝试移动文本视图,为线性布局网格创建更多 space,但仍然没有用。
activity 的截图:
https://imgur.com/a/I2wEgZW
这是Activity代码:
import android.content.Intent;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import java.util.ArrayList;
public class Badges extends AppCompatActivity {
private static String TAG = "Badges.Class";
private static ImageView badge1,badge2, badge3, badge4, badge5, badge6, badge7, badge8, badge9, questionBadge;
private Button summaryButton;
public static int b1, b2, b3, b4, b5, b6, b7, b8, b9;
public static String currentUser;
public static int badgePoints;
public static TextView textPointsValue;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_badges);
//Creating Badge Icons and greying them out
badge1 = findViewById(R.id.imageBadge1);
badge2 = findViewById(R.id.imageBadge2);
badge3 = findViewById(R.id.imageBadge3);
badge4 = findViewById(R.id.imageBadge4);
badge5 = findViewById(R.id.imageBadge5);
badge6 = findViewById(R.id.imageBadge6);
badge7 = findViewById(R.id.imageBadge7);
badge8 = findViewById(R.id.imageBadge8);
badge9 = findViewById(R.id.imageBadge9);
badge1.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
badge2.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
badge3.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
badge4.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
badge5.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
badge6.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
badge7.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
badge8.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
badge9.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
//Creating Summary Button
summaryButton = findViewById(R.id.summaryButtonBadge);
summaryButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent myIntent = new Intent(Badges.this,BadgesSummary.class);
startActivity(myIntent);
}
});
//Create Back Button
ImageView backButton = findViewById(R.id.badgeBackButton);
backButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent myIntent = new Intent(Badges.this,Home.class);
startActivity(myIntent);
}
});
//Question Mark Button
//Have yet to set up logic for this
questionBadge = findViewById(R.id.questionButBadge);
questionBadge.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//******Add Logic in here*****
}
});
//Points text
textPointsValue = findViewById(R.id.textPointsValue);
Log.d(TAG, "onCreate: the value of current user is " + currentUser);
//Staged Scenarios
if(currentUser.equals("test")){
//badge1.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
Log.d(TAG, "onCreate: Ran the currentUser test method, and the value of current " +
"user " + currentUser);
badgePoints = 0;
badge1.setColorFilter(null);
addPoints(50);
b1=1;
badge2.setColorFilter(null);
addPoints(200);
b2=1;
badge3.setColorFilter(null);
addPoints(300);
b3=1;
badge4.setColorFilter(null);
addPoints(50);
b4=1;
}
else if(currentUser == "gg"){
}
else if(currentUser == "jason"){
}
//Scenario one
}
//Public method to reset the values
public static void resetBadge (){
//This resets all badges.
//Should only be ran when a new user is created.
b1 = 0;
b2 = 0;
b3 = 0;
b4 = 0;
b5 = 0;
b6 = 0;
b7 = 0;
b8 = 0;
b9 = 0;
badgePoints=0;
textPointsValue.setText(String.valueOf(badgePoints));
Log.d(TAG, "resetBadge: Badges have been reset due to new user login");
}
public static void setCurrentUser(String user){
Badges.currentUser = user;
Log.d(TAG, "setCurrentUser: User has been updated " + user);
}
public static void addPoints(int value){
badgePoints = badgePoints + value;
textPointsValue.setText(String.valueOf(badgePoints));
}
public static void achieveBadge1(){
//Create Avatar and profile
if(b1 == 0){
badge1.setColorFilter(null);
addPoints(50);
b1=1;
}
}
public static void achieveBadge2(){
//Choose major
if(b2 == 0){
badge2.setColorFilter(null);
addPoints(200);
b2=1;
}
}
public static void achieveBadge3(){
//Finish Degree
if(b3 == 0){
badge3.setColorFilter(null);
addPoints(300);
b3=1;
}
}
public static void achieveBadge4(){
//Redeem a Reward
if(b4 == 0){
badge4.setColorFilter(null);
addPoints(50);
b4=1;
}
}
public static void achieveBadge5(){
//Log in 7 days
if(b5 == 0){
badge5.setColorFilter(null);
addPoints(100);
b5=1;
}
}
public static void achieveBadge6(){
//Earn 500 points
if(b6 == 0){
badge6.setColorFilter(null);
addPoints(100);
b6=1;
}
}
public static void achieveBadge7(){
//Reviewed a Course
if(b7 == 0){
badge7.setColorFilter(null);
addPoints(200);
b7=1;
}
}
public static void achieveBadge8(){
//Saved a course
if(b8 == 0){
badge8.setColorFilter(null);
addPoints(50);
b1=1;
}
}
public static void achieveBadge9(){
//Update a wam
if(b9 == 0){
badge9.setColorFilter(null);
addPoints(100);
b9=1;
}
}
}
这是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"
tools:context=".Badges">
<ImageView
android:id="@+id/badgeBackButton"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_marginStart="3dp"
android:layout_marginTop="29dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/back_arrow" />
<ImageView
android:id="@+id/questionButBadge"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/question" />
<TextView
android:id="@+id/textPointsBadge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="176dp"
android:layout_marginEnd="176dp"
android:text="Points"
android:textColor="@color/colorLightPurple"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textPointsValue" />
<TextView
android:id="@+id/textPointsValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="176dp"
android:layout_marginEnd="177dp"
android:text="650"
android:textColor="@color/colorLightPurple"
android:textSize="35sp"
app:layout_constraintBottom_toTopOf="@+id/textPointsBadge"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView13" />
<TextView
android:id="@+id/badgesText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="139dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="139dp"
android:gravity="center"
android:text="Badges"
android:textAlignment="center"
android:textColor="@color/colorLightPurple"
android:textSize="40dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/summaryButtonBadge"
android:layout_width="161dp"
android:layout_height="48dp"
android:layout_marginStart="69dp"
android:layout_marginEnd="69dp"
android:layout_marginBottom="20dp"
android:background="@drawable/purple_square_button"
android:text="See Summary"
android:textAllCaps="false"
android:textColor="@color/colorWhite"
android:textSize="17dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<LinearLayout
android:id="@+id/linIconGrid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="10dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textPointsBadge">
<LinearLayout
android:id="@+id/linTopRow"
android:layout_width="match_parent"
android:layout_height="114dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageBadge1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
app:srcCompat="@drawable/badge1" />
<ImageView
android:id="@+id/imageBadge2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
app:srcCompat="@drawable/badge2" />
<ImageView
android:id="@+id/imageBadge3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
app:srcCompat="@drawable/badge3" />
</LinearLayout>
<LinearLayout
android:id="@+id/linMidRow"
android:layout_width="match_parent"
android:layout_height="114dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageBadge4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
app:srcCompat="@drawable/badge4" />
<ImageView
android:id="@+id/imageBadge5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
app:srcCompat="@drawable/badge5" />
<ImageView
android:id="@+id/imageBadge6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
app:srcCompat="@drawable/badge6" />
</LinearLayout>
<LinearLayout
android:id="@+id/linBotRow"
android:layout_width="match_parent"
android:layout_height="114dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageBadge7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
app:srcCompat="@drawable/badge7" />
<ImageView
android:id="@+id/imageBadge8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
app:srcCompat="@drawable/badge8" />
<ImageView
android:id="@+id/imageBadge9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
app:srcCompat="@drawable/badge9" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/imageView13"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginStart="178dp"
android:layout_marginEnd="178dp"
android:textAlignment="center"
app:layout_constraintBottom_toTopOf="@+id/textPointsValue"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/badgesText"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@drawable/onboarding2_logo2" />
</android.support.constraint.ConstraintLayout>
我认为您的布局超出了屏幕尺寸但没有滚动。您已经为某些布局元素分配了固定大小。尝试使用 nestedScrollView 封闭 constraintLayout。
但还要注意一件事:
<LinearLayout
android:id="@+id/linIconGrid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="10dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textPointsBadge">
为什么要使用 match_parent 作为 constraintLayout 的直接子项?如果要使用全宽,请将宽度设置为 0dp 并使用这些
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
我发现使用的图像太大(就容量而言,例如每个 7mb)。我缩小了图像的尺寸,一切都开始正常工作。
我目前 运行 activity 在模拟器 (Nexus 5X API 27) 上运行良好,但是在设备 (Samsung S8 Plus) 上执行它时;线性布局网格不会出现。我已经添加了适当的约束,但它们仍然没有显示。
尝试移动文本视图,为线性布局网格创建更多 space,但仍然没有用。
activity 的截图: https://imgur.com/a/I2wEgZW
这是Activity代码:
import android.content.Intent;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import java.util.ArrayList;
public class Badges extends AppCompatActivity {
private static String TAG = "Badges.Class";
private static ImageView badge1,badge2, badge3, badge4, badge5, badge6, badge7, badge8, badge9, questionBadge;
private Button summaryButton;
public static int b1, b2, b3, b4, b5, b6, b7, b8, b9;
public static String currentUser;
public static int badgePoints;
public static TextView textPointsValue;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_badges);
//Creating Badge Icons and greying them out
badge1 = findViewById(R.id.imageBadge1);
badge2 = findViewById(R.id.imageBadge2);
badge3 = findViewById(R.id.imageBadge3);
badge4 = findViewById(R.id.imageBadge4);
badge5 = findViewById(R.id.imageBadge5);
badge6 = findViewById(R.id.imageBadge6);
badge7 = findViewById(R.id.imageBadge7);
badge8 = findViewById(R.id.imageBadge8);
badge9 = findViewById(R.id.imageBadge9);
badge1.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
badge2.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
badge3.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
badge4.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
badge5.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
badge6.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
badge7.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
badge8.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
badge9.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
//Creating Summary Button
summaryButton = findViewById(R.id.summaryButtonBadge);
summaryButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent myIntent = new Intent(Badges.this,BadgesSummary.class);
startActivity(myIntent);
}
});
//Create Back Button
ImageView backButton = findViewById(R.id.badgeBackButton);
backButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent myIntent = new Intent(Badges.this,Home.class);
startActivity(myIntent);
}
});
//Question Mark Button
//Have yet to set up logic for this
questionBadge = findViewById(R.id.questionButBadge);
questionBadge.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//******Add Logic in here*****
}
});
//Points text
textPointsValue = findViewById(R.id.textPointsValue);
Log.d(TAG, "onCreate: the value of current user is " + currentUser);
//Staged Scenarios
if(currentUser.equals("test")){
//badge1.setColorFilter(this.getResources().getColor(R.color.transparentDarken));
Log.d(TAG, "onCreate: Ran the currentUser test method, and the value of current " +
"user " + currentUser);
badgePoints = 0;
badge1.setColorFilter(null);
addPoints(50);
b1=1;
badge2.setColorFilter(null);
addPoints(200);
b2=1;
badge3.setColorFilter(null);
addPoints(300);
b3=1;
badge4.setColorFilter(null);
addPoints(50);
b4=1;
}
else if(currentUser == "gg"){
}
else if(currentUser == "jason"){
}
//Scenario one
}
//Public method to reset the values
public static void resetBadge (){
//This resets all badges.
//Should only be ran when a new user is created.
b1 = 0;
b2 = 0;
b3 = 0;
b4 = 0;
b5 = 0;
b6 = 0;
b7 = 0;
b8 = 0;
b9 = 0;
badgePoints=0;
textPointsValue.setText(String.valueOf(badgePoints));
Log.d(TAG, "resetBadge: Badges have been reset due to new user login");
}
public static void setCurrentUser(String user){
Badges.currentUser = user;
Log.d(TAG, "setCurrentUser: User has been updated " + user);
}
public static void addPoints(int value){
badgePoints = badgePoints + value;
textPointsValue.setText(String.valueOf(badgePoints));
}
public static void achieveBadge1(){
//Create Avatar and profile
if(b1 == 0){
badge1.setColorFilter(null);
addPoints(50);
b1=1;
}
}
public static void achieveBadge2(){
//Choose major
if(b2 == 0){
badge2.setColorFilter(null);
addPoints(200);
b2=1;
}
}
public static void achieveBadge3(){
//Finish Degree
if(b3 == 0){
badge3.setColorFilter(null);
addPoints(300);
b3=1;
}
}
public static void achieveBadge4(){
//Redeem a Reward
if(b4 == 0){
badge4.setColorFilter(null);
addPoints(50);
b4=1;
}
}
public static void achieveBadge5(){
//Log in 7 days
if(b5 == 0){
badge5.setColorFilter(null);
addPoints(100);
b5=1;
}
}
public static void achieveBadge6(){
//Earn 500 points
if(b6 == 0){
badge6.setColorFilter(null);
addPoints(100);
b6=1;
}
}
public static void achieveBadge7(){
//Reviewed a Course
if(b7 == 0){
badge7.setColorFilter(null);
addPoints(200);
b7=1;
}
}
public static void achieveBadge8(){
//Saved a course
if(b8 == 0){
badge8.setColorFilter(null);
addPoints(50);
b1=1;
}
}
public static void achieveBadge9(){
//Update a wam
if(b9 == 0){
badge9.setColorFilter(null);
addPoints(100);
b9=1;
}
}
}
这是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"
tools:context=".Badges">
<ImageView
android:id="@+id/badgeBackButton"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_marginStart="3dp"
android:layout_marginTop="29dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/back_arrow" />
<ImageView
android:id="@+id/questionButBadge"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/question" />
<TextView
android:id="@+id/textPointsBadge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="176dp"
android:layout_marginEnd="176dp"
android:text="Points"
android:textColor="@color/colorLightPurple"
android:textSize="18sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textPointsValue" />
<TextView
android:id="@+id/textPointsValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="176dp"
android:layout_marginEnd="177dp"
android:text="650"
android:textColor="@color/colorLightPurple"
android:textSize="35sp"
app:layout_constraintBottom_toTopOf="@+id/textPointsBadge"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView13" />
<TextView
android:id="@+id/badgesText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="139dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="139dp"
android:gravity="center"
android:text="Badges"
android:textAlignment="center"
android:textColor="@color/colorLightPurple"
android:textSize="40dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/summaryButtonBadge"
android:layout_width="161dp"
android:layout_height="48dp"
android:layout_marginStart="69dp"
android:layout_marginEnd="69dp"
android:layout_marginBottom="20dp"
android:background="@drawable/purple_square_button"
android:text="See Summary"
android:textAllCaps="false"
android:textColor="@color/colorWhite"
android:textSize="17dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<LinearLayout
android:id="@+id/linIconGrid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="10dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textPointsBadge">
<LinearLayout
android:id="@+id/linTopRow"
android:layout_width="match_parent"
android:layout_height="114dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageBadge1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
app:srcCompat="@drawable/badge1" />
<ImageView
android:id="@+id/imageBadge2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
app:srcCompat="@drawable/badge2" />
<ImageView
android:id="@+id/imageBadge3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
app:srcCompat="@drawable/badge3" />
</LinearLayout>
<LinearLayout
android:id="@+id/linMidRow"
android:layout_width="match_parent"
android:layout_height="114dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageBadge4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
app:srcCompat="@drawable/badge4" />
<ImageView
android:id="@+id/imageBadge5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
app:srcCompat="@drawable/badge5" />
<ImageView
android:id="@+id/imageBadge6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
app:srcCompat="@drawable/badge6" />
</LinearLayout>
<LinearLayout
android:id="@+id/linBotRow"
android:layout_width="match_parent"
android:layout_height="114dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageBadge7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
app:srcCompat="@drawable/badge7" />
<ImageView
android:id="@+id/imageBadge8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
app:srcCompat="@drawable/badge8" />
<ImageView
android:id="@+id/imageBadge9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="5dp"
app:srcCompat="@drawable/badge9" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/imageView13"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginStart="178dp"
android:layout_marginEnd="178dp"
android:textAlignment="center"
app:layout_constraintBottom_toTopOf="@+id/textPointsValue"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/badgesText"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@drawable/onboarding2_logo2" />
</android.support.constraint.ConstraintLayout>
我认为您的布局超出了屏幕尺寸但没有滚动。您已经为某些布局元素分配了固定大小。尝试使用 nestedScrollView 封闭 constraintLayout。
但还要注意一件事:
<LinearLayout
android:id="@+id/linIconGrid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="10dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textPointsBadge">
为什么要使用 match_parent 作为 constraintLayout 的直接子项?如果要使用全宽,请将宽度设置为 0dp 并使用这些
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
我发现使用的图像太大(就容量而言,例如每个 7mb)。我缩小了图像的尺寸,一切都开始正常工作。