标签: android-custom-view

Android 自定义组件不显示其子组件

大家好,我想FieldSet在 Android 中创建一个组件。(类似html),所以像那个。所以我希望我的自定义组件有孩子并有一个板。电路板部分已经完成,但我在显示组件时遇到了一些问题。我正在关注这个答案。这是我的部分:

字段集.java :

public class FieldSet extends ViewGroup {

  //... 3 constructors

  @Override
  protected void onFinishInflate()
    int index = getChildCount();
    // Collect children declared in XML.
    View[] children = new View[index];
    while(--index >= 0) {
      children[index] = getChildAt(index);
    }
    // Pressumably, wipe out existing content (still holding reference to it).
    this.detachAllViewsFromParent();
    // Inflate new "template".
    final View template = LayoutInflater.from(getContext()).inflate(R.layout.field_set, this, true);
    // Obtain reference to a new container within …
Run Code Online (Sandbox Code Playgroud)

android custom-component android-custom-view layout-inflater

0
推荐指数
1
解决办法
1549
查看次数

在自定义视图中获取 RecyclerView 方向

我正在尝试创建一个扩展的自定义视图RecyclerViewRecyclerView在我的自定义视图中,我根据方向(水平或垂直)要做一些事情。

不幸的是,我找不到任何方法来了解和获得RecyclerView方向。

甚至有可能做到吗?

我知道RecyclerView方向是在其定义的LayoutManager。也许无法获得这些LayoutManager信息?

预先感谢您提供的任何帮助。

java android android-custom-view android-recyclerview

0
推荐指数
1
解决办法
1999
查看次数

在android中动态替换另一个视图的视图?

我已经在我的xml布局文件中添加了自定义视图,即FancyCoverFlow.我想以编程方式在同一位置用视频视图替换此视图.意味着不应该更改其他视图位置.应该在布局文件中显示它们.但只有我的自定义视图应替换为具有与FancyCoverFlow相同的位置坐标的视频视图.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/layout"
xmlns:fcf="http://schemas.android.com/apk/res-auto"
android:background="@drawable/bga"

android:orientation="vertical" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Large Text"
    android:textColor="#fff"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Medium Text"
    android:textColor="#fff"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Medium Text"
    android:textColor="#fff"
    android:textAppearance="?android:attr/textAppearanceMedium" />      

<imageslideractivty.FancyCoverFlow
    android:id="@+id/fancyCoverFlow"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:layout_marginTop="10dp"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"        
    fcf:maxRotation="45"
    fcf:unselectedAlpha="0.3"
    fcf:unselectedSaturation="0.0"
    fcf:unselectedScale="0.4"
    fcf:scaleDownGravity="0.5"/>
 <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    >

 <SeekBar
    android:id="@+id/slider"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:layout_centerHorizontal="true"
    android:progressDrawable="@null"
    android:thumb="@drawable/middle"
    android:layout_marginBottom="20dp" />
</LinearLayout>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

android android-custom-view android-videoview

-1
推荐指数
2
解决办法
3664
查看次数

Android:动作栏主页按钮获得额外的填充

我正在开发一个应用程序,我在其中自定义操作栏,如图所示:

行动吧

我的代码如下:

// Remove all tabs from actionbar
getActionBar().removeAllTabs();

final ViewGroup actionBarLayout = (ViewGroup)getLayoutInflater().inflate(R.layout.custom_actionbar_layout, null);
// set custom layout for menus on actionbar
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_USE_LOGO);
getActionBar().setCustomView(actionBarLayout);

getActionBar().setBackgroundDrawable(new ColorDrawable(Color.WHITE));
getActionBar().setDisplayHomeAsUpEnabled(false);
getActionBar().setLogo(R.drawable.ic_back_orange);

final TextView textViewOfActionBarHeading = (TextView) actionBarLayout.findViewById(R.id.textView_actionar_heading);
textViewOfActionBarHeading.setText("My Activity");

// Getting the reference of searchViewand TextView of searchView
SearchView searchView = (SearchView) actionBarLayout.findViewById(R.id.searchView_actionar_search);
searchView.setIconifiedByDefault(true);
final TextView search_text = (TextView) searchView.findViewById(searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null));

// Set color to TextView of searchView
search_text.setTextColor(Color.BLACK);
// Set hint to TextView of …
Run Code Online (Sandbox Code Playgroud)

android android-custom-view android-actionbar

-1
推荐指数
1
解决办法
1725
查看次数