页脚图像不会正确尺寸 [英] Footer Image Will Not Size Correctly

查看:206
本文介绍了页脚图像不会正确尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个似乎不正确的大小页脚形象:它被切断在每边,似乎与其他图像(分配给PagerAdapter以及)重叠。

这又如何避免?

截图:

Java代码:

 私有类ImagePagerAdapter扩展PagerAdapter {
    私人诠释[] = mImages新INT [] {
            R.drawable.classical_up_btn,
            R.drawable.country_up_btn,
            R.drawable.dance_up_btn,
            R.drawable.hiphop_up_btn
    };    公众诠释的getCount(){
        返回mImages.length;
    }    公共布尔isViewFromObject(查看视图,Object对象){
        返回查看==((ImageView的)对象);
    }    公共对象instantiateItem(ViewGroup中的容器,INT位置){
        上下文的背景下= Home.this;
        ImageView的ImageView的=新ImageView的(上下文);
        INT填充= context.getResources()。
                getDimensionPixelSize(R.dimen.padding_medium);
        imageView.setPadding(填充,填充,填充,填充);
        imageView.setScaleType(ImageView.ScaleType.CENTER);
        imageView.setImageResource(mImages [位置]);
        ((ViewPager)容器).addView(ImageView的,0);
        返回ImageView的;
    }    @覆盖
    公共无效destroyItem(ViewGroup中的容器,INT位置,Object对象){
        ((ViewPager)容器).removeView((ImageView的)对象);
    }
 }
}

XML:

 <?XML版本=1.0编码=UTF-8&GT?;
< android.support.v4.widget.DrawerLayout的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@ + ID / drawer_layout
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent>    <的LinearLayout
        机器人:ID =@ + ID / content_frame
        机器人:layout_width =match_parent
        机器人:layout_height =match_parent
        机器人:背景=@绘制/ ic_drawer
        机器人:方向=垂直>
    < / LinearLayout中>    < ListView控件
        机器人:ID =@ + ID / left_drawer
        机器人:layout_width =280dp
        机器人:layout_height =match_parent
        机器人:layout_gravity =开始
        机器人:背景=@彩色/ darkgrey
        机器人:choiceMode =singleChoice
        机器人:分=@机器人:彩色/透明
        机器人:dividerHeight =0dp/>    <的TextView
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_gravity =CENTER_HORIZONTAL
        机器人:自动链接=网
        机器人:文字样式=大胆/>    < RelativeLayout的
        机器人:ID =@ + ID / RL
        机器人:layout_width =match_parent
        机器人:layout_height =match_parent
        机器人:背景=#AAFFFFFF>        <滚动型
            机器人:ID =@ + ID / groupScrollView
            机器人:layout_width =match_parent
            机器人:layout_height =match_parent>            <的LinearLayout
                机器人:layout_width =match_parent
                机器人:layout_height =WRAP_CONTENT
                机器人:方向=垂直>                < com.google.android.youtube.player.YouTubePlayerView
                    机器人:ID =@ + ID / youtubeplayerview
                    机器人:layout_width =match_parent
                    机器人:layout_height =WRAP_CONTENT/>                <的LinearLayout
                    机器人:layout_width =match_parent
                    机器人:layout_height =WRAP_CONTENT
                    机器人:方向=横向>                    <的TextView
                        机器人:ID =@ + ID / textView1a
                        机器人:layout_width =0dip
                        机器人:layout_height =WRAP_CONTENT
                        机器人:layout_weight =1
                        机器人:文字=投掷及放大器;者;举起手来
                        机器人:textAppearance =机器人:ATTR / textAppearanceMedium/>                    <按钮
                        机器人:ID =@ + ID / fav_up_btn1
                        机器人:layout_width =27dp
                        机器人:layout_height =27dp
                        机器人:layout_alignParentTop =真
                        机器人:layout_toRightOf =@ + ID / textView1a
                        机器人:背景=@绘制/ fav_up_btn1
                        机器人:重力=右
                        机器人:paddingRight =5DP
                        机器人:paddingTop =5DP/>
                < / LinearLayout中>                <的LinearLayout
                    机器人:layout_width =match_parent
                    机器人:layout_height =WRAP_CONTENT
                    机器人:方向=横向>                    <的TextView
                        机器人:ID =@ + ID / textView2a
                        机器人:layout_width =WRAP_CONTENT
                        机器人:layout_height =WRAP_CONTENT
                        机器人:layout_toLeftOf =@ + ID / textView3a
                        机器人:重力=左
                        机器人:文字=由DJ通用|
                        机器人:textAppearance =机器人:ATTR / textAppearanceSmall
                        机器人:文字颜色=@色/浅灰/>                    <的TextView
                        机器人:ID =@ + ID / textView3a
                        机器人:layout_width =0dp
                        机器人:layout_height =WRAP_CONTENT
                        机器人:layout_weight =1
                        机器人:重力=左
                        机器人:文字=10万人次​​
                        机器人:textAppearance =:/>中的Andr​​oid ATTR / textAppearanceSmall?
                < / LinearLayout中>                <查看
                    机器人:layout_width =1DP
                    机器人:layout_height =25dp>
                < /视图>                < com.google.android.youtube.player.YouTubeThumbnailView
                    机器人:ID =@ + ID / youtubethumbnailview1
                    机器人:layout_width =match_parent
                    机器人:layout_height =200dip
                    机器人:scaleType =fitXY/>                <的LinearLayout
                    机器人:layout_width =match_parent
                    机器人:layout_height =WRAP_CONTENT
                    机器人:方向=横向>                    <的TextView
                        机器人:ID =@ + ID / textView1a
                        机器人:layout_width =WRAP_CONTENT
                        机器人:layout_height =WRAP_CONTENT
                        机器人:layout_weight =1
                        机器人:文字=公牛队游行
                        机器人:textAppearance =机器人:ATTR / textAppearanceMedium/>                    <按钮
                        机器人:ID =@ + ID / fav_up_btn
                        机器人:layout_width =27dp
                        机器人:layout_height =27dp
                        机器人:layout_alignParentTop =真
                        机器人:layout_toRightOf =@ + ID / textView1a
                        机器人:背景=@绘制/ fav_up_btn1
                        机器人:重力=右
                        机器人:paddingRight =5DP
                        机器人:paddingTop =5DP/>
                < / LinearLayout中>                <的LinearLayout
                    机器人:layout_width =match_parent
                    机器人:layout_height =WRAP_CONTENT
                    机器人:方向=横向>                    <的TextView
                        机器人:ID =@ + ID / textView2a
                        机器人:layout_width =WRAP_CONTENT
                        机器人:layout_height =WRAP_CONTENT
                        机器人:layout_toLeftOf =@ + ID / textView3a
                        机器人:重力=左
                        机器人:文字=由愤怒反对机器|
                        机器人:textAppearance =机器人:ATTR / textAppearanceSmall
                        机器人:文字颜色=@色/浅灰/>                    <的TextView
                        机器人:ID =@ + ID / textView3a
                        机器人:layout_width =0dp
                        机器人:layout_height =WRAP_CONTENT
                        机器人:layout_weight =1
                        机器人:重力=左
                        机器人:文字=10万人次​​
                        机器人:textAppearance =:/>中的Andr​​oid ATTR / textAppearanceSmall?
                < / LinearLayout中>                <查看
                    机器人:layout_width =1DP
                    机器人:layout_height =25dp>
                < /视图>                < com.google.android.youtube.player.YouTubeThumbnailView
                    机器人:ID =@ + ID / youtubethumbnailview2
                    机器人:layout_width =match_parent
                    机器人:layout_height =200dip
                    机器人:scaleType =fitXY/>                <的LinearLayout
                    机器人:layout_width =match_parent
                    机器人:layout_height =WRAP_CONTENT
                    机器人:方向=横向>                    <的TextView
                        机器人:ID =@ + ID / textView1a
                        机器人:layout_width =WRAP_CONTENT
                        机器人:layout_height =WRAP_CONTENT
                        机器人:layout_weight =1
                        机器人:文字=艾萨克丹尼尔在CNN与安德森·库珀
                        机器人:textAppearance =机器人:ATTR / textAppearanceMedium/>                    <按钮
                        机器人:ID =@ + ID / fav_up_btn
                        机器人:layout_width =27dp
                        机器人:layout_height =27dp
                        机器人:layout_alignParentTop =真
                        机器人:layout_toRightOf =@ + ID / textView1a
                        机器人:背景=@绘制/ fav_up_btn1
                        机器人:重力=右
                        机器人:paddingRight =5DP
                        机器人:paddingTop =5DP/>
                < / LinearLayout中>                <的LinearLayout
                    机器人:layout_width =match_parent
                    机器人:layout_height =WRAP_CONTENT
                    机器人:方向=横向>                    <的TextView
                        机器人:ID =@ + ID / textView2a
                        机器人:layout_width =WRAP_CONTENT
                        机器人:layout_height =WRAP_CONTENT
                        机器人:layout_toLeftOf =@ + ID / textView3a
                        机器人:重力=左
                        机器人:文字=由idconex |
                        机器人:textAppearance =机器人:ATTR / textAppearanceSmall
                        机器人:文字颜色=@色/浅灰/>                    <的TextView
                        机器人:ID =@ + ID / textView3a
                        机器人:layout_width =0dp
                        机器人:layout_height =WRAP_CONTENT
                        机器人:layout_toRightOf =@ + ID / textView2a
                        机器人:layout_weight =1
                        机器人:重力=左
                        机器人:文字=10万人次​​
                        机器人:textAppearance =:/>中的Andr​​oid ATTR / textAppearanceSmall?
                < / LinearLayout中>                <查看
                    机器人:layout_width =1DP
                    机器人:layout_height =25dp>
                < /视图>                < com.google.android.youtube.player.YouTubeThumbnailView
                    机器人:ID =@ + ID / youtubethumbnailview3
                    机器人:layout_width =match_parent
                    机器人:layout_height =200dip
                    机器人:scaleType =fitXY/>                <的LinearLayout
                    机器人:layout_width =match_parent
                    机器人:layout_height =WRAP_CONTENT
                    机器人:方向=横向>                    <的TextView
                        机器人:ID =@ + ID / textView1a
                        机器人:layout_width =WRAP_CONTENT
                        机器人:layout_height =WRAP_CONTENT
                        机器人:layout_weight =1
                        机器人:文字=公牛队游行
                        机器人:textAppearance =机器人:ATTR / textAppearanceMedium/>                    <按钮
                        机器人:ID =@ + ID / fav_up_btn
                        机器人:layout_width =27dp
                        机器人:layout_height =27dp
                        机器人:layout_alignParentTop =真
                        机器人:layout_toRightOf =@ + ID / textView1a
                        机器人:背景=@绘制/ fav_up_btn1
                        机器人:重力=右
                        机器人:paddingRight =5DP
                        机器人:paddingTop =5DP/>
                < / LinearLayout中>                <的LinearLayout
                    机器人:layout_width =match_parent
                    机器人:layout_height =WRAP_CONTENT
                    机器人:方向=横向>                    <的TextView
                        机器人:ID =@ + ID / textView2a
                        机器人:layout_width =WRAP_CONTENT
                        机器人:layout_height =WRAP_CONTENT
                        机器人:layout_toLeftOf =@ + ID / textView3a
                        机器人:重力=左
                        机器人:文字=由愤怒反对机器|
                        机器人:textAppearance =机器人:ATTR / textAppearanceSmall
                        机器人:文字颜色=@色/浅灰/>                    <的TextView
                        机器人:ID =@ + ID / textView3a
                        机器人:layout_width =0dp
                        机器人:layout_height =WRAP_CONTENT
                        机器人:layout_weight =1
                        机器人:重力=左
                        机器人:文字=10万人次​​
                        机器人:textAppearance =:/>中的Andr​​oid ATTR / textAppearanceSmall?
                < / LinearLayout中>                <查看
                    机器人:layout_width =1DP
                    机器人:layout_height =25dp>
                < /视图>                < com.google.android.youtube.player.YouTubeThumbnailView
                    机器人:ID =@ + ID / youtubethumbnailview4
                    机器人:layout_width =match_parent
                    机器人:layout_height =200dip
                    机器人:scaleType =fitXY/>                <的LinearLayout
                    机器人:layout_width =match_parent
                    机器人:layout_height =WRAP_CONTENT
                    机器人:方向=横向>                    <的TextView
                        机器人:ID =@ + ID / textView1a
                        机器人:layout_width =WRAP_CONTENT
                        机器人:layout_height =WRAP_CONTENT
                        机器人:layout_weight =1
                        机器人:文字=艾萨克丹尼尔在CNN与安德森·库珀
                        机器人:textAppearance =机器人:ATTR / textAppearanceMedium/>                    <按钮
                        机器人:ID =@ + ID / fav_up_btn
                        机器人:layout_width =27dp
                        机器人:layout_height =27dp
                        机器人:layout_alignParentTop =真
                        机器人:layout_toRightOf =@ + ID / textView1a
                        机器人:背景=@绘制/ fav_up_btn1
                        机器人:重力=右
                        机器人:paddingRight =5DP
                        机器人:paddingTop =5DP/>
                < / LinearLayout中>                <的LinearLayout
                    机器人:layout_width =match_parent
                    机器人:layout_height =WRAP_CONTENT
                    机器人:方向=横向>                    <的TextView
                        机器人:ID =@ + ID / textView2a
                        机器人:layout_width =WRAP_CONTENT
                        机器人:layout_height =WRAP_CONTENT
                        机器人:layout_toLeftOf =@ + ID / textView3a
                        机器人:重力=左
                        机器人:文字=由idconex |
                        机器人:textAppearance =机器人:ATTR / textAppearanceSmall
                        机器人:文字颜色=@色/浅灰/>                    <的TextView
                        机器人:ID =@ + ID / textView3a
                        机器人:layout_width =0dp
                        机器人:layout_height =WRAP_CONTENT
                        机器人:layout_weight =1
                        机器人:重力=左
                        机器人:文字=10万人次​​
                        机器人:textAppearance =:/>中的Andr​​oid ATTR / textAppearanceSmall?                    <查看
                        机器人:layout_width =1DP
                        机器人:layout_height =75dp>
                    < /视图>
                < / LinearLayout中>
            < / LinearLayout中>
        < /滚动型>        < RelativeLayout的
            机器人:ID =@ + ID /页脚
            机器人:layout_width =FILL_PARENT
            机器人:layout_height =70dip
            机器人:layout_alignParentBottom =真
            机器人:背景=@色/ darkgrey>            <的ImageButton
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_gravity =左
                机器人:SRC =@绘制/ home_up_btn/>            < Horizo​​ntalScrollView
                机器人:ID =@ + ID / groupScrollView
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =match_parent
                机器人:背景=@色/ darkgrey>                <的ImageButton
                    机器人:layout_width =FILL_PARENT
                    机器人:layout_height =match_parent
                    机器人:layout_gravity =CENTER_HORIZONTAL
                    机器人:背景=@彩色/ darkgrey
                    机器人:SRC =@绘制/ selstation_up_btn/>
            < / Horizo​​ntalScrollView>            <的ImageButton
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_alignParentLeft =真
                机器人:SRC =@绘制/ scroll_lt_arrow/>            <的ImageButton
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:layout_alignParentRight =真
                机器人:SRC =@绘制/ scroll_rt_arrow/>            < android.support.v4.view.ViewPager
                机器人:ID =@ + ID / view_pager
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT/>
        < / RelativeLayout的>
    < / RelativeLayout的>< /android.support.v4.widget.DrawerLayout>


解决方案

如果您使用CENTER,FIT_XY,或任何其他类似的参数,你需要指定查看的确切尺寸,而不是使用 match_parent FILL_PARENT 等,如果你想使用父布局参数,那么你就需要用

 可绘制D = getResources()getDrawable(drawable_id)。
imageView.setImageBitmap(((BitmapDrawable情况)​​d).getBitmap());

I have a footer image which does not seem to size correctly: it is cut off on every side and appears to overlap with other images (assigned to the PagerAdapter as well).

How can this be avoided?

Screenshot:

JAVA SNIPPET:

private class ImagePagerAdapter extends PagerAdapter {
    private int[] mImages = new int[] {
            R.drawable.classical_up_btn,
            R.drawable.country_up_btn,
            R.drawable.dance_up_btn,
            R.drawable.hiphop_up_btn
    };

    public int getCount() {
        return mImages.length;
    }

    public boolean isViewFromObject(View view, Object object) {
        return view == ((ImageView) object);
    }

    public Object instantiateItem(ViewGroup container, int position) {
        Context context = Home.this;
        ImageView imageView = new ImageView(context);
        int padding =context.getResources().  
                getDimensionPixelSize(R.dimen.padding_medium);
        imageView.setPadding(padding, padding, padding, padding);
        imageView.setScaleType(ImageView.ScaleType.CENTER);
        imageView.setImageResource(mImages[position]);
        ((ViewPager) container).addView(imageView, 0); 
        return imageView;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        ((ViewPager) container).removeView((ImageView) object);
    }
 }
}

XML:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/ic_drawer"
        android:orientation="vertical" >
    </LinearLayout>

    <ListView
        android:id="@+id/left_drawer"
        android:layout_width="280dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@color/darkgrey"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:autoLink="web"
        android:textStyle="bold" />

    <RelativeLayout
        android:id="@+id/rl"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#AAFFFFFF" >

        <ScrollView
            android:id="@+id/groupScrollView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical" >

                <com.google.android.youtube.player.YouTubePlayerView
                    android:id="@+id/youtubeplayerview"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />

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

                    <TextView
                        android:id="@+id/textView1a"
                        android:layout_width="0dip"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="Throw &apos;Em Up"
                        android:textAppearance="?android:attr/textAppearanceMedium" />

                    <Button
                        android:id="@+id/fav_up_btn1"
                        android:layout_width="27dp"
                        android:layout_height="27dp"
                        android:layout_alignParentTop="true"
                        android:layout_toRightOf="@+id/textView1a"
                        android:background="@drawable/fav_up_btn1"
                        android:gravity="right"
                        android:paddingRight="5dp"
                        android:paddingTop="5dp" />
                </LinearLayout>

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

                    <TextView
                        android:id="@+id/textView2a"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_toLeftOf="@+id/textView3a"
                        android:gravity="left"
                        android:text="by DJ Generic  |"
                        android:textAppearance="?android:attr/textAppearanceSmall"
                        android:textColor="@color/lightgrey" />

                    <TextView
                        android:id="@+id/textView3a"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="left"
                        android:text="  100,000 views"
                        android:textAppearance="?android:attr/textAppearanceSmall" />
                </LinearLayout>

                <View
                    android:layout_width="1dp"
                    android:layout_height="25dp" >
                </View>

                <com.google.android.youtube.player.YouTubeThumbnailView
                    android:id="@+id/youtubethumbnailview1"
                    android:layout_width="match_parent"
                    android:layout_height="200dip"
                    android:scaleType="fitXY" />

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

                    <TextView
                        android:id="@+id/textView1a"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="Bulls On Parade"
                        android:textAppearance="?android:attr/textAppearanceMedium" />

                    <Button
                        android:id="@+id/fav_up_btn"
                        android:layout_width="27dp"
                        android:layout_height="27dp"
                        android:layout_alignParentTop="true"
                        android:layout_toRightOf="@+id/textView1a"
                        android:background="@drawable/fav_up_btn1"
                        android:gravity="right"
                        android:paddingRight="5dp"
                        android:paddingTop="5dp" />
                </LinearLayout>

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

                    <TextView
                        android:id="@+id/textView2a"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_toLeftOf="@+id/textView3a"
                        android:gravity="left"
                        android:text="by Rage Against The Machine  |"
                        android:textAppearance="?android:attr/textAppearanceSmall"
                        android:textColor="@color/lightgrey" />

                    <TextView
                        android:id="@+id/textView3a"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="left"
                        android:text="  100,000 views"
                        android:textAppearance="?android:attr/textAppearanceSmall" />
                </LinearLayout>

                <View
                    android:layout_width="1dp"
                    android:layout_height="25dp" >
                </View>

                <com.google.android.youtube.player.YouTubeThumbnailView
                    android:id="@+id/youtubethumbnailview2"
                    android:layout_width="match_parent"
                    android:layout_height="200dip"
                    android:scaleType="fitXY" />

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

                    <TextView
                        android:id="@+id/textView1a"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="Isaac Daniel on CNN with Anderson Cooper"
                        android:textAppearance="?android:attr/textAppearanceMedium" />

                    <Button
                        android:id="@+id/fav_up_btn"
                        android:layout_width="27dp"
                        android:layout_height="27dp"
                        android:layout_alignParentTop="true"
                        android:layout_toRightOf="@+id/textView1a"
                        android:background="@drawable/fav_up_btn1"
                        android:gravity="right"
                        android:paddingRight="5dp"
                        android:paddingTop="5dp" />
                </LinearLayout>

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

                    <TextView
                        android:id="@+id/textView2a"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_toLeftOf="@+id/textView3a"
                        android:gravity="left"
                        android:text="by idconex  |"
                        android:textAppearance="?android:attr/textAppearanceSmall"
                        android:textColor="@color/lightgrey" />

                    <TextView
                        android:id="@+id/textView3a"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_toRightOf="@+id/textView2a"
                        android:layout_weight="1"
                        android:gravity="left"
                        android:text="  100,000 views"
                        android:textAppearance="?android:attr/textAppearanceSmall" />
                </LinearLayout>

                <View
                    android:layout_width="1dp"
                    android:layout_height="25dp" >
                </View>

                <com.google.android.youtube.player.YouTubeThumbnailView
                    android:id="@+id/youtubethumbnailview3"
                    android:layout_width="match_parent"
                    android:layout_height="200dip"
                    android:scaleType="fitXY" />

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

                    <TextView
                        android:id="@+id/textView1a"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="Bulls On Parade"
                        android:textAppearance="?android:attr/textAppearanceMedium" />

                    <Button
                        android:id="@+id/fav_up_btn"
                        android:layout_width="27dp"
                        android:layout_height="27dp"
                        android:layout_alignParentTop="true"
                        android:layout_toRightOf="@+id/textView1a"
                        android:background="@drawable/fav_up_btn1"
                        android:gravity="right"
                        android:paddingRight="5dp"
                        android:paddingTop="5dp" />
                </LinearLayout>

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

                    <TextView
                        android:id="@+id/textView2a"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_toLeftOf="@+id/textView3a"
                        android:gravity="left"
                        android:text="by Rage Against The Machine  |"
                        android:textAppearance="?android:attr/textAppearanceSmall"
                        android:textColor="@color/lightgrey" />

                    <TextView
                        android:id="@+id/textView3a"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="left"
                        android:text="  100,000 views"
                        android:textAppearance="?android:attr/textAppearanceSmall" />
                </LinearLayout>

                <View
                    android:layout_width="1dp"
                    android:layout_height="25dp" >
                </View>

                <com.google.android.youtube.player.YouTubeThumbnailView
                    android:id="@+id/youtubethumbnailview4"
                    android:layout_width="match_parent"
                    android:layout_height="200dip"
                    android:scaleType="fitXY" />

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

                    <TextView
                        android:id="@+id/textView1a"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:text="Isaac Daniel on CNN with Anderson Cooper"
                        android:textAppearance="?android:attr/textAppearanceMedium" />

                    <Button
                        android:id="@+id/fav_up_btn"
                        android:layout_width="27dp"
                        android:layout_height="27dp"
                        android:layout_alignParentTop="true"
                        android:layout_toRightOf="@+id/textView1a"
                        android:background="@drawable/fav_up_btn1"
                        android:gravity="right"
                        android:paddingRight="5dp"
                        android:paddingTop="5dp" />
                </LinearLayout>

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

                    <TextView
                        android:id="@+id/textView2a"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_toLeftOf="@+id/textView3a"
                        android:gravity="left"
                        android:text="by idconex  |"
                        android:textAppearance="?android:attr/textAppearanceSmall"
                        android:textColor="@color/lightgrey" />

                    <TextView
                        android:id="@+id/textView3a"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:gravity="left"
                        android:text="  100,000 views"
                        android:textAppearance="?android:attr/textAppearanceSmall" />

                    <View
                        android:layout_width="1dp"
                        android:layout_height="75dp" >
                    </View>
                </LinearLayout>
            </LinearLayout>
        </ScrollView>

        <RelativeLayout
            android:id="@+id/footer"
            android:layout_width="fill_parent"
            android:layout_height="70dip"
            android:layout_alignParentBottom="true"
            android:background="@color/darkgrey" >

            <ImageButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="left"
                android:src="@drawable/home_up_btn" />

            <HorizontalScrollView
                android:id="@+id/groupScrollView"
                android:layout_width="fill_parent"
                android:layout_height="match_parent"
                android:background="@color/darkgrey" >

                <ImageButton
                    android:layout_width="fill_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center_horizontal"
                    android:background="@color/darkgrey"
                    android:src="@drawable/selstation_up_btn" />
            </HorizontalScrollView>

            <ImageButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:src="@drawable/scroll_lt_arrow" />

            <ImageButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:src="@drawable/scroll_rt_arrow" />

            <android.support.v4.view.ViewPager
                android:id="@+id/view_pager"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </RelativeLayout>
    </RelativeLayout>

</android.support.v4.widget.DrawerLayout>

解决方案

If you use CENTER, FIT_XY, or any of the other similar parameters you need to specify an exact size for the View rather than using match_parent, fill_parent, etc. If you do want to use the parent layout parameters then you will need to specify the image in java source with

Drawable d = getResources().getDrawable(drawable_id);
imageView.setImageBitmap(((BitmapDrawable) d).getBitmap());

这篇关于页脚图像不会正确尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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