开发者

How can I display an image and its url side by side in android

I want to display an image and the url of it side by side.

How c开发者_高级运维an I achieve this?


To be honest, you question is not a good one and doesn't really fit the requirements here. Anyway, as you seem to be a totally beginner and because thats your first question here (welcome!), I will provde some infos.

Two kind of views do you need. The first one will be an ImageView where you can display your image with. The second one can be a simple TextView where you can set the text to the URL.

To make them displayed side by side, you need a LinearLayout with the orientation set to horizontal. Inside that layout you can place the ImageView and than the TextView. Both views should have the layout_width set to wrap_content and the layout_weight to 1.

In your activity you can then set the image to the ImageView and the URL to the TextView.

Here is the simple xml layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="horizontal"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <ImageView
    android:src="@drawable/icon"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_weight="1"/>
  <TextView
    android:text="dummytext"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_weight="1"/>
</LinearLayout>

A LinearLayout tutorial can be found in the official docs where a lot of views and layouts are shown and explained.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜