当配置文件活动显示时,导航抽屉工具栏不显示

问题描述 投票:0回答:1

我的问题是我的导航抽屉工具栏隐藏在配置文件活动的装饰后面。我浏览了这样的问题,我得到的唯一可能的解决方案是将约束布局更改为线性布局,但如果没有约束,我不知道倒置的弯曲矩形将如何保持。请帮忙! 配置文件活动.xml `

   <?xml version="1.0" encoding="utf-8"?>
     <androidx.constraintlayout.widget.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="#E1E1E1"
android:backgroundTint="#E1E1E1"
tools:context=".ProfileActivity">

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/constraintLayout"
                    android:layout_width="match_parent"
                    android:layout_height="200dp"
                    android:background="@drawable/top_bkg"
                    tools:ignore="MissingConstraints"
                    tools:layout_editor_absoluteX="-205dp"
                    tools:layout_editor_absoluteY="0dp">

                    <de.hdodenhof.circleimageview.CircleImageView
                        android:id="@+id/Pic"
                        android:layout_width="150dp"
                        android:layout_height="150dp"
                        android:src="@drawable/outline_person_24"
                        android:textAlignment="center"
                        app:civ_border_color="@color/white"
                        app:civ_border_width="3dp"
                        tools:ignore="MissingConstraints"
                        tools:layout_editor_absoluteX="130dp"
                        tools:layout_editor_absoluteY="120dp" />
                </androidx.constraintlayout.widget.ConstraintLayout>

                <LinearLayout
                    android:id="@+id/linearLayout"
                    android:layout_width="match_parent"
                    android:layout_height="250dp"
                    android:layout_marginStart="16dp"
                    android:layout_marginTop="328dp"
                    android:layout_marginEnd="16dp"
                    android:background="@drawable/white_bkg"
                    android:orientation="vertical"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintHorizontal_bias="0.0"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:orientation="horizontal">

                        <TextView
                            android:id="@+id/Name"
                            android:layout_width="15dp"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="10dp"
                            android:layout_marginTop="10dp"
                            android:layout_marginBottom="10dp"
                            android:layout_weight="1"
                            android:text="@string/nameLbl"
                            android:textColor="#182693"
                            android:textSize="16sp" />

                        <TextView
                            android:id="@+id/nmTxt"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="10dp"
                            android:layout_marginTop="10dp"
                            android:layout_marginEnd="12dp"
                            android:layout_marginBottom="10dp"
                            android:layout_weight="1"
                            android:textAlignment="viewEnd"
                            android:textColor="#182693"
                            android:textSize="16sp"
                            tools:ignore="SpeakableTextPresentCheck" />

                    </LinearLayout>

                    <View
                        android:id="@+id/view"
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="6dp"
                        android:layout_marginEnd="10dp"
                        android:layout_marginBottom="6dp"
                        android:background="#D9D9D9" />

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:orientation="horizontal">


                        <TextView
                            android:id="@+id/Mobile"
                            android:layout_width="15dp"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="10dp"
                            android:layout_marginTop="10dp"
                            android:layout_marginBottom="10dp"
                            android:layout_weight="1"
                            android:text="@string/mobileLbl"
                            android:textColor="#182693"
                            android:textSize="16sp" />

                        <TextView
                            android:id="@+id/mobileTxt"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="10dp"
                            android:layout_marginTop="10dp"
                            android:layout_marginEnd="12dp"
                            android:layout_marginBottom="10dp"
                            android:layout_weight="1"

                            android:textAlignment="viewEnd"
                            android:textColor="#182693"
                            android:textSize="16sp"
                            tools:ignore="SpeakableTextPresentCheck" />

                    </LinearLayout>

                    <View
                        android:id="@+id/view1"
                        android:layout_width="match_parent"
                        android:layout_height="1dp"
                        android:layout_marginStart="10dp"
                        android:layout_marginTop="6dp"
                        android:layout_marginEnd="10dp"
                        android:layout_marginBottom="6dp"
                        android:background="#D9D9D9" />

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_margin="10dp"
                        android:orientation="horizontal">

                        <TextView
                            android:id="@+id/eMail"
                            android:layout_width="15dp"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="10dp"
                            android:layout_marginTop="10dp"
                            android:layout_marginBottom="10dp"
                            android:layout_weight="1"
                            android:text="@string/e_mailLbl"
                            android:textColor="#182693"
                            android:textSize="16sp"
                            tools:ignore="TextSizeCheck" />

                        <TextView
                            android:id="@+id/emText"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginStart="10dp"
                            android:layout_marginTop="10dp"
                            android:layout_marginEnd="12dp"
                            android:layout_marginBottom="10dp"
                            android:layout_weight="1"

                            android:text=""
                            android:textAlignment="viewEnd"
                            android:textColor="#182693"
                            android:textSize="16sp"
                            tools:ignore="SpeakableTextPresentCheck" />

                    </LinearLayout>


                </LinearLayout>


            </androidx.constraintlayout.widget.ConstraintLayout>
        </androidx.constraintlayout.widget.ConstraintLayout>
    </LinearLayout>
</ScrollView>


 </androidx.constraintlayout.widget.ConstraintLayout>`

我的抽屉基础活动 `

  <androidx.drawerlayout.widget.DrawerLayout 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=".DrawerBaseActivity"
tools:openDrawer="start"
android:fitsSystemWindows="true"
>
 <include layout="@layout/content_layout"
android:layout_height="match_parent"
android:layout_width="match_parent"

/>
<com.google.android.material.navigation.NavigationView
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:layout_gravity="start"
    android:id="@+id/nav_view"
    app:headerLayout="@layout/main_drawer_header"
    app:menu="@menu/main_drawer_menu"
    />

  </androidx.drawerlayout.widget.DrawerLayout>`

配置文件activity.java `
包 com.example.login_page_simple;

 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.HttpURLConnection;
 import java.net.URL;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
//earlier it was public class ProfileActivity extends drawerbaseactivity

public class ProfileActivity extends DrawerBaseActivity{
ActivityProfileBinding activityProfileBinding;
TextView etRole, etEmail, etExId, etAdId, etName, etMob;
ImageView imageView;
SharedPrefMANAGER sharedPrefMANAGER;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    activityProfileBinding = ActivityProfileBinding.inflate(getLayoutInflater());
    allocateActivityTitle("Profile");
    setContentView(activityProfileBinding.getRoot());

    etName = findViewById(R.id.nmTxt);
    etMob = findViewById(R.id.mobileTxt);
  //etRole= findViewById(R.id.roleTxt);
    etEmail = findViewById(R.id.emText);
    //etExId=findViewById(R.id.exIdTxt);
    //etAdId=findViewById(R.id.adminTxt);
    imageView = findViewById(R.id.Pic);
    sharedPrefMANAGER = new SharedPrefMANAGER(getApplicationContext());

    etName.setText(sharedPrefMANAGER.getObj().getName());
    etMob.setText(sharedPrefMANAGER.getObj().getMobile());
    //etRole.setText(sharedPrefMANAGER.getObj().getRole());
    etEmail.setText(sharedPrefMANAGER.getObj().getEmail());
    //etExId.setText(sharedPrefMANAGER.getObj().getExam_id());
    //etAdId.setText(sharedPrefMANAGER.getObj().getAdmin_id());
    List<String> imagePath = sharedPrefMANAGER.getObj().getImages();
    //String imageUrl = "https://w7.pngwing.com/pngs/421/258/png-transparent-mark-zuckerberg-facebook-f8-social-networking-service-mark-zuckerberg-celebrities-face-head.png";
    //Picasso.get().load(imageUri).into(imageView);
    ExecutorService executor = Executors.newSingleThreadExecutor();
    executor.execute(new Runnable() {
        @Override
        public void run() {
            try {
                if(!imagePath.isEmpty()){
                    String brakyUrl=imagePath.get(0);
                    String imageUrl=brakyUrl.replaceAll("\\[|\\]", "");
                    URL url = new URL(imageUrl); // imagePath is the URL to the image
                    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                    connection.setDoInput(true);
                    connection.connect();
                    InputStream input = connection.getInputStream();
                    final Bitmap bitmap = BitmapFactory.decodeStream(input);
                    //imageView.setImageBitmap(bitmap);
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            imageView.setImageBitmap(bitmap);
                        }
                    });
                }
                else{
                    Log.e("ImageLoading","No url");
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });`
java android xml layout
1个回答
0
投票

您可以尝试将整个布局包装在 CoordinatorLayout 中,并使用 AppBarLayout 创建工具栏,如下所示,并在活动文件中的 onCreate 上访问它,如下所示 -

工具栏工具栏 = findViewById(R.id.toolbar); setSupportActionBar(工具栏);

<androidx.coordinatorlayout.widget.CoordinatorLayout
    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="#E1E1E1"
    android:backgroundTint="#E1E1E1"
    tools:context=".ProfileActivity">

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@drawable/top_bkg"
            app:layout_scrollFlags="scroll|enterAlways">

          

        </androidx.appcompat.widget.Toolbar>

    </com.google.android.material.appbar.AppBarLayout>

    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <!-- Your existing content goes here -->

    </androidx.core.widget.NestedScrollView>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
© www.soinside.com 2019 - 2024. All rights reserved.