android - Loading image in the Navigation Drawer header from custom URL -
i not using custom library make navigation view. using navigation view support design library. how able set header image custom image internet using glide or fresco. have static imageview drawer header.
edit - image needs of size?
you can set in xml file
navigation header
:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto" android:background="@color/colorprimarydark" android:gravity="center_vertical" android:orientation="vertical" android:paddingbottom="@dimen/nav_header_margin_bottom" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/nav_header_margin_top" android:theme="@style/themeoverlay.appcompat.dark"> <imageview android:id="@+id/imageview" android:layout_width="match_parent" android:layout_height="match_parent" android:adjustviewbounds="true" android:scaletype="fitxy"/> </linearlayout>
and use glide
set image url in mainactivity
:
private navigationview navigationview; @override protected void oncreate(bundle savedinstancestate) { //navigationheader view header = navigationview.getheaderview(0); imageview = (imageview) header.findviewbyid(r.id.imageview); glide .with(context) .load("your url") .placeholder(r.drawable.priceshoes) .error(r.drawable.priceshoes) .into(imageview); }
Comments
Post a Comment