android-将imageview放在彼此下面的两个textview旁边 [英] android - Place imageview next to two textviews under each other

查看:88
本文介绍了android-将imageview放在彼此下面的两个textview旁边的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在android studio中创建以上布局?

解决方案

首先在gradle文件中为

How do i create above layout in android studio ?

解决方案

First add dependencies in your gradle file for circular image view

 compile 'de.hdodenhof:circleimageview:2.1.0'

now you can use below code as per your requirement

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="3">

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center">

        <de.hdodenhof.circleimageview.CircleImageView
            android:id="@+id/meal_image_order"
            android:layout_width="96dp"
            android:layout_height="96dp"
            android:src="@color/colorAccent"
            app:civ_border_color="@color/colorPrimaryDark"
            app:civ_border_width="2dp" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="2"
        android:gravity="center"
        android:orientation="vertical">

        <TextView
            android:id="@+id/tv1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Textview 1" />

        <TextView
            android:id="@+id/tv2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Textview 2" />

    </LinearLayout>
</LinearLayout>
</LinearLayout>

sample output

这篇关于android-将imageview放在彼此下面的两个textview旁边的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆