请图像出现在屏幕的一半 [英] Make image appear half of the screen

查看:126
本文介绍了请图像出现在屏幕的一半的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法让我的ImageView出现半个屏幕可以有人帮忙的。这里是我的XML文件。它应该采取的屏幕尺寸的一半,并还与TextView的线性布局应该在imageview的页脚

I am having trouble to make my imageview appear half of the screen can someone help. here is my xml file. It should take up half of the screen size and also the linear layout with the textview should be at the footer of the imageview.

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="@drawable/fond" >

<RelativeLayout

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:layout_alignParentLeft="true"

    android:layout_below="@+id/relativeLayout1" >

    <RelativeLayout

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        android:layout_alignParentLeft="true" >

        <WebView

            android:id="@+id/webcontent"

            android:layout_width="match_parent"

            android:layout_height="wrap_content"

            android:layout_alignParentLeft="true"

            android:layout_alignParentTop="true"

            android:layout_marginTop="151dp" />

    </RelativeLayout>

    <ImageView

        android:id="@+id/image_actualitedetails"

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        android:layout_alignParentTop="true"

        android:layout_centerHorizontal="true"

        android:src="@drawable/six_yamaha" />

    <LinearLayout

        android:id="@+id/linearvideo"

        android:layout_width="fill_parent"

        android:layout_height="65dp"

        android:layout_alignBottom="@+id/image_actualitedetails"

        android:layout_alignParentLeft="true"

        android:background="#88FFFFFF"

        android:gravity="center"

        android:paddingLeft="@dimen/fourdp"

        android:paddingRight="@dimen/fourdp" >


        <TextView

            android:id="@+id/text_actualites"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:text="TextView"

            android:textColor="@color/tabDark"

            android:textStyle="bold" />

    </LinearLayout>


</RelativeLayout>

<RelativeLayout

    android:id="@+id/relativeLayout1"

    android:layout_width="fill_parent"

    android:layout_height="75dp"

    android:layout_alignParentLeft="true"

    android:layout_alignParentTop="true"

    android:background="@drawable/header" >

    <Button

        android:id="@+id/boutton_retour"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_alignParentLeft="true"

        android:layout_centerVertical="true"

        android:layout_marginLeft="14dp"

        android:background="@drawable/back" />

</RelativeLayout>

推荐答案

使用LinearyLayout来包装你的ImageView和其他无形的景观,并设置layout_weight既为0.5,那么ImageView的应该是一半大小。

Use LinearyLayout to wrap your ImageView and another invisible View, and set layout_weight both to 0.5, then the ImageView should be half the size.

下面是一个例子给你展示了如何设置图像一半的屏幕尺寸

Here is an example for you showing how to set the image half the screen size

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.5"
        android:background="#ff0000"
        >
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/your_image"
            android:adjustViewBounds="true"
            />
    </RelativeLayout>
    <View
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="0.5"
        android:background="#00ff00"
        />
</LinearLayout>

这是结果

如果你想要把你的形象在屏幕的中心,你可以用同样的想法,并设置适当的重量来实现自己的目标。祝你好运!

If you want to put your image in center of the screen, you can use the same idea and set proper weight to achieve your goal. Good luck!

这篇关于请图像出现在屏幕的一半的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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