如何正确allign意见根据设计? [英] How to allign views properly according to a design?

查看:449
本文介绍了如何正确allign意见根据设计?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设计师做了一些设计我的Andr​​oid应用程序,这里是一个设计,一个ListView(不是真实的,但同样的想法..):

a designer made some design for my Android app, here is a design for a ListView (not the real one but the same idea..):

因此​​,在绿色区域的中间有一些文字,并在橙色区域的ImageView的(可点击..),并在蓝色区域中间的另一个文本..这是1列表视图..所以,如果你刷卡一行另外也刷卡一样。(他们不是3列表视图。)黄色区域是空的。

So in the middle of the green area there is some text, and in the orange area an imageview (clickable..), and in the middle of the blue area another text.. this is 1 listview.. so if you swipe one row the other also swipe the same.. (they arent 3 listviews..) The yellow area is empty

我如何调整的意见,所以它适用于所有的屏幕尺寸?我如何中心的绿色和蓝色区域中的文本?
谢谢

How do I align the views so it works on all screen sizes? How can I center the text in the green and blue area?
Thanks

下面是我用行的XML:

Here is the xml of the row I used:

<?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:orientation="horizontal"
android:layout_height="wrap_content" android:paddingLeft="40dip"
android:paddingRight="40dip">
<TextView android:id="@+id/Start_Numbering" android:textSize="19.5sp"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:layout_weight="0.3" 
    />

<ImageView android:id="@+id/Start_ImageView"
    android:layout_weight="0.1" android:layout_height="wrap_content"
    android:layout_width="fill_parent"        android:src="@drawable/list_noaudioavailable"
    ></ImageView>


<TextView android:id="@+id/Start_Name" android:textColor="#a7e9fe"
    android:textSize="21dip" android:layout_width="fill_parent"
    android:layout_weight="0.6"
    android:layout_height="wrap_content" />

下面是getView:

Here is getView:

 @Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder     holder;

    if(convertView == null) {
        convertView = mInflater.inflate(R.layout.start_row, null); //line 47
        holder=new ViewHolder();

        holder.tv_Name   =(TextView)convertView.findViewById(R.id.Start_Name);
        holder.tv_PageNumber = (TextView)convertView.findViewById(R.id.Start_Numbering);
        holder.im_Audio=(ImageView)convertView.findViewById(R.id.Start_ImageView);
        convertView.setTag(holder);
    } else {
        holder  = (ViewHolder) convertView.getTag();
    }

    holder.tv_Name.setText(Names[position]);
    holder.tv_PageNumber.setText(Integer.toString(PageNumber[position]));
    return convertView;
}

class ViewHolder {
    TextView       tv_Name;
    TextView       tv_PageNumber;
    ImageView      im_Audio;
}

不过,我得到的是这样的,为什么tv_Name心不是被显示?:

But all I get is this, why the tv_Name isnt being display?:

推荐答案

奥马尔,你的问题是不是一清二楚,但我会给它一个镜头。

Omar, your questions wasn't crystal clear, but I will give it a shot.

您使用

在你row.xml,你可以使用

In your row.xml, you would use

  1. 的LinearLayout作为父与取向水平
  2. 这将有五个子元素

  1. LinearLayout as the parent with orientation as horizontal
  2. It will have five child elements

  • 一个。与layout_weight = 2黄视图
  • 乙。蓝色文本字段与layout_weight = 5
  • ℃。橙色的ImageField与layout_weight = 3
  • Ð。 绿色文本字段与layout_weight = 4
  • 如与黄查看 layout_weight = 1
  • a. Yellow View with layout_weight=2
  • b. Blue TextField with layout_weight=5
  • c. Orange ImageField with layout_weight=3
  • d. Green TextField with layout_weight=4
  • e. Yellow View with layout_weight=1

有关居中文本使用相应的文本对齐属性。所有这些元素应layout_width定义为FILL_PARENT

For centering the text use appropriate text align property. All of these elements should have layout_width defined as fill_parent.

这篇关于如何正确allign意见根据设计?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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