如何在Android工作室制作像个人资料图片框架的个人资料图片上传框架? [英] How to make profile picture uploder frame like Facebook profile pic frame in android studio?
问题描述
我将图像带到.xml文件,当用户从设备或图库上传图像时将显示用户配置文件,默认情况下,图像视图将是默认图像。使用Android Studio。所以请帮我解决这个问题。
我尝试过的事情:
<?xml version =1.0encoding =utf-8?>
< FrameLayout 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
app:layout_behavior = @ string / appbar_scrolling_view_behavior
工具:context =com.example.vixcy.thecontacts.dashboard
工具:showIn =@ layout / app_bar_nav_drawer>
< TextView
android:id =@ + id / textView1
android:layout_width =300dp
android:layout_height =30dp
android:layout_marginLeft =40dp
android: layout_marginTop =300dp
android:text =TextView
android:gravity =center
android:textColor =#000000
android:textStyle = 粗体/>
< LinearLayout
android:layout_width =200sp
android: layout_height =200sp
android:layout_marginLeft =85sp
android:layout_marginTop =50sp
android:orientation =vertical >
< ImageView
android:id =@ + id / imgView
android:layout_width =fill_parent
android:layout_height =wrap_content
android:layout_weight =10
android:adjustViewBounds =true
android:cropToPadding =true
android:elevation =10dp
android:padding = 1dp
android:scaleType =centerCrop
android:visibility =visible
app:srcCompat =@ mipmap / dummy>
<按钮
android:id =@ + id / buttonLoadPicture
= android:layout_width =wrap_contentandroid:layout_height =wrap_contentandroid:layout_gravity =centerandroid:layout_weight =0android:onclick =onClickandroid:text =Load Picture>
< TextView
android:id = @ + id / textView2
android:layout_width =300dp
android:layout_height =30dp
android:layout_marginLeft = 40dp
android:layout_marginTop =350dp
android:text =TextView
android:gravity =center
android:textColor =#000000
android:textStyle =bold/>
android:src =@ drawable / dummy
而不是
app:srcCompat =@ mipmap / dummy
此外,您应该将默认图像放入可绘制文件夹,而不是mipmap文件夹。 Mipmap文件夹仅用于图标。
你可以看到与这篇文章的区别
android - mipmap vs drawable folders - Stack Overflow [ ^ ]
I take image to .xml file where user profile is going to display when user did upload image from device or gallery and by default place of image view it will be default image. using Android Studio. So please help me out of this problem.
What I have tried:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.vixcy.thecontacts.dashboard"
tools:showIn="@layout/app_bar_nav_drawer">
<TextView
android:id="@+id/textView1"
android:layout_width="300dp"
android:layout_height="30dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="300dp"
android:text="TextView"
android:gravity="center"
android:textColor="#000000"
android:textStyle="bold"/>
<LinearLayout
android:layout_width="200sp"
android:layout_height="200sp"
android:layout_marginLeft="85sp"
android:layout_marginTop="50sp"
android:orientation="vertical">
<ImageView
android:id="@+id/imgView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
android:adjustViewBounds="true"
android:cropToPadding="true"
android:elevation="10dp"
android:padding="1dp"
android:scaleType="centerCrop"
android:visibility="visible"
app:srcCompat="@mipmap/dummy">
<button
android:id="@+id/buttonLoadPicture"
="" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="0" android:onclick="onClick" android:text="Load Picture">
<TextView
android:id="@+id/textView2"
android:layout_width="300dp"
android:layout_height="30dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="350dp"
android:text="TextView"
android:gravity="center"
android:textColor="#000000"
android:textStyle="bold"/>
Useandroid:src="@drawable/dummy"instead of
app:srcCompat="@mipmap/dummy"Also, you should put the default image to drawable folder, not mipmap folder. Mipmap folder is only for icon.
You can see the difference from this post
android - mipmap vs drawable folders - Stack Overflow[^]
这篇关于如何在Android工作室制作像个人资料图片框架的个人资料图片上传框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!