Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 我怎样才能进入可牵引设备?_Android_Android Layout_Android Fragments_Xamarin - Fatal编程技术网

Android 我怎样才能进入可牵引设备?

Android 我怎样才能进入可牵引设备?,android,android-layout,android-fragments,xamarin,Android,Android Layout,Android Fragments,Xamarin,我有一个这样的布局(用于片段): 我将此形状作为上述布局中文本视图的背景: <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <solid android:color="#ffffff" /> <stroke android:width="1dip" android:color="#

我有一个这样的布局(用于片段):


我将此形状作为上述布局中文本视图的背景:

  <shape xmlns:android="http://schemas.android.com/apk/res/android"
     android:shape="rectangle">
        <solid android:color="#ffffff" />
        <stroke android:width="1dip" android:color="#4fa5d5"/>
  </shape>

我需要改变可拉丝的颜色。如何从代码中访问它

我基本上有许多片段的实例显示,我需要从特定片段访问背景绘图。

您可以这样做:

View v = findViewById(R.id.Text_Value);
ShapeDrawable d = (ShapeDrawable) v.getBackground();
或者,如果您有对特定片段的引用:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:minWidth="25px"
   android:minHeight="25px">
<TextView
    android:id="@+id/Text_Value"
    android:text="0"
    android:textSize="32dp"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/PlaySquareShape"/>
</RelativeLayout>
View v = frag.getView().findViewById(R.id.Text_Value);
您可以这样做:

View v = findViewById(R.id.Text_Value);
ShapeDrawable d = (ShapeDrawable) v.getBackground();
或者,如果您有对特定片段的引用:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:minWidth="25px"
   android:minHeight="25px">
<TextView
    android:id="@+id/Text_Value"
    android:text="0"
    android:textSize="32dp"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/PlaySquareShape"/>
</RelativeLayout>
View v = frag.getView().findViewById(R.id.Text_Value);
您可以这样做:

View v = findViewById(R.id.Text_Value);
ShapeDrawable d = (ShapeDrawable) v.getBackground();
或者,如果您有对特定片段的引用:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:minWidth="25px"
   android:minHeight="25px">
<TextView
    android:id="@+id/Text_Value"
    android:text="0"
    android:textSize="32dp"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/PlaySquareShape"/>
</RelativeLayout>
View v = frag.getView().findViewById(R.id.Text_Value);
您可以这样做:

View v = findViewById(R.id.Text_Value);
ShapeDrawable d = (ShapeDrawable) v.getBackground();
或者,如果您有对特定片段的引用:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:minWidth="25px"
   android:minHeight="25px">
<TextView
    android:id="@+id/Text_Value"
    android:text="0"
    android:textSize="32dp"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/PlaySquareShape"/>
</RelativeLayout>
View v = frag.getView().findViewById(R.id.Text_Value);

完美的我试试看。谢谢:)这方面我还是新手。它奏效了!!唯一不同的是我的背景是一个GradientDrawable:)完美!我试试看。谢谢:)这方面我还是新手。它奏效了!!唯一不同的是我的背景是一个GradientDrawable:)完美!我试试看。谢谢:)这方面我还是新手。它奏效了!!唯一不同的是我的背景是一个GradientDrawable:)完美!我试试看。谢谢:)这方面我还是新手。它奏效了!!唯一的区别是我的背景是GradientDrawable:)