我的应用中有2个EditText
观看次数:
<?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="fill_parent"
android:background="@color/white">
<MyProject.MyView
android:id="@+id/view1"
android:layout_width="match_parent"
android:layout_height="60dp" />
<EditText
android:id="@+id/view2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/black"
style="@style/my_style"
android:hint="my hint2"/>
以下是MyProject.MyView
public class MyView : LinearLayout
{
// not important code...
public LinearLayout Panel { get; private set; }
// Gets called from the constructor:
private void Init()
{
var layoutInflater = (LayoutInflater)this.Context.GetSystemService(Android.Content.Context.LayoutInflaterService);
this.content = layoutInflater.Inflate(Resource.Layout.my_content, this.Panel, true);
this.AddView(this.content);
}
}
这是my_content
:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
style="@style/my_style2">
<EditText
android:id="@+id/view1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/my_style"
android:hint="my hint">
</EditText>
</LinearLayout>
第一个EditText
(从我的MyView
课程中被充气)与父母的宽度不匹配,它只会包裹内容。但第二个EditText
与父亲的宽度相匹配。为什么呢?
答案 0 :(得分:1)
我通过在<RelativeLayout>
xml中用my_content
包裹var searchString = channelName;
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("ChannelViews");
var column = 1;
var columnValues = sheet.getRange(2, column, sheet.getLastRow()).getValues();
var searchResult = columnValues.findIndex(searchString);
return searchResult;
来解决这个问题。我不确定为什么需要这样做,所以我仍然会欣赏一个解释,以便我能更好地理解Android的工作方式。