gpt4 book ai didi

java - Android - 如何在代码中使 TextView fill_parent

转载 作者:行者123 更新时间:2023-12-01 04:34:38 29 4
gpt4 key购买 nike

我试图让我的 TextView layout_width 填充父抛出代码。这是我的代码:

 TextView WatchMovieTitle;

private void PrintTheMovieAndYear() {
if (CountWords() > 23) {
// this is what im doing wrong
// WatchMovieTitle.setLayoutParams
// (new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

WatchMovieTitle.setText(movieList.get("movieName") + " " + "("
+ movieList.get("movieYear") + ")");
WatchMovieYear.setVisibility(View.GONE);
} else {
WatchMovieYear
.setText(" " + "(" + movieList.get("movieYear") + ")");

}
}

谢谢!

最佳答案

您可以使用

LayoutParams lp=new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);

LayoutParams lp=new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);

基于 TextView 的父布局。

关于java - Android - 如何在代码中使 TextView fill_parent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17504922/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com