【问题标题】:cant display view in android studio无法在 android studio 中显示视图
【发布时间】:2020-09-25 19:32:05
【问题描述】:

嗨,我是 android studio 的新手,我想在视图组内添加一个视图,视图组显示正确,但视图内没有。这是代码:

class Bookview extends ViewGroup
{
    public Bookview(Context context,int height)
    {
        super(context);

         height = 732;
         int heightx = height/2;


        this.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,height));
        this.setBackgroundColor(Color.parseColor("#327dcf"));
 
      //view to add
        HorizontalScrollView myview = new HorizontalScrollView(context);
        myview.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT,heightx));
        myview.setBackgroundColor(Color.parseColor("#dd42f5"));
        this.addView(myview);
      }  
  }

}

这是我在布局检查器中得到的,视图已添加但未显示。 有什么问题?

【问题讨论】:

    标签: java android android-studio android-layout


    【解决方案1】:

    你需要在 Horizo​​ntalScrollView 里面添加数据

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多