Several knowledge points derived from the home page interface (4)

Description: Copying a collection by means of new ArrayList<T>(List<T> srcList) creates a separate memory space, and the content is the same as that of the source collection. Modifications to the new collection do not affect the source collection.
Layout a and then b, can you use code to dynamically modify a on b?
When setting the control layout:
[javascript] view plaincopy    
  1. LayoutParams leftTxtParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);  
Method 1: addRule(int verb)
[javascript] view plaincopy    
  1. leftTxtParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);  


Method 2: addRule(int verb, int anchor)
[javascript] view plaincopy    
  1. leftTxtParams.addRule(RelativeLayout.END_OF, img_left.getId());  
The second parameter here is the control ID. You can click to view the control ID: android sets the ID and setId() exception for the new control in the code



<RelativeLayout
android :id= "@+id/ll_tab_layout_container"
android :layout_width= "match_parent"
android :layout_height= "match_parent"
android :fillViewport= "true"
app :layout_behavior= "@string/appbar_scrolling_view_behavior" >

<android.support.v7. widget .CardView
android :id= "@+id/card_column"
style= "@style/home_card_style"
android :layout_alignParentTop= "true"
android :layout_width= "match_parent"
android :layout_height= "wrap_content"
android :layout_marginBottom= "7dp"
android :layout_marginTop= "5dp" >

<RelativeLayout
android :layout_width= "match_parent"
android :layout_height= "match_parent"
android :orientation= "vertical" >

<com.dx168.efsmobile.me.widget.HomeCardTitleLayout
android :id= "@+id/column_more"
android :layout_width= "match_parent"
android :layout_height= "wrap_content"
app :contentIcon= "@drawable/hundreds_icon"
app :contentText= "百家专栏"
app :rightIcon= "@drawable/home_right_more_arrow"
app :rightText= "查看更多" />

<FrameLayout
android :id= "@+id/cloumn_fragment"
android :layout_width= "match_parent"
android :layout_height= "match_parent"
android :layout_below= "@+id/column_more" />
</RelativeLayout>
</android.support.v7. widget .CardView>

<android.support.v7. widget .CardView
android :id= "@id/card_image"
style= "@style/home_card_style"
android :layout_width= "match_parent"
android :layout_height= "wrap_content"
android :layout_below= "@id/card_column"
android :layout_marginBottom= "7dp"
android :layout_marginTop= "5dp" >

<ImageView
android :id= "@+id/personal"
android :layout_width= "match_parent"
android :layout_height= "72dp"
android :scaleType= "fitXY" />
</android.support.v7. widget .CardView>

<FrameLayout
android :id= "@+id/fl_live_container_bottom"
android :layout_below= "@id/card_image"
android :layout_width= "match_parent"
android :layout_height= "wrap_content" />
</RelativeLayout>



if (isActiveUser){
RelativeLayout.LayoutParams imgParams = (RelativeLayout.LayoutParams) mImgCardView .getLayoutParams() ;
imgParams.addRule(RelativeLayout. BELOW , 0 ) ;
imgParams.addRule(RelativeLayout. ALIGN_PARENT_TOP ) ;
mImgCardView .setLayoutParams(imgParams) ;
RelativeLayout.LayoutParams columnParams = (RelativeLayout.LayoutParams) mlColumnCardView .getLayoutParams() ;
columnParams.addRule(RelativeLayout. ALIGN_PARENT_TOP , 0 ) ;
columnParams.addRule(RelativeLayout. BELOW , mImgCardView .getId()) ; //or params
mlColumnCardView .setLayoutParams(columnParams) ;

} else {
RelativeLayout.LayoutParams columnParams = (RelativeLayout.LayoutParams) mlColumnCardView .getLayoutParams() ;
columnParams .addRule(RelativeLayout. BELOW , 0 ) ;
columnParams .addRule(RelativeLayout. ALIGN_PARENT_TOP ) ;
mlColumnCardView .setLayoutParams( columnParams ) ;
RelativeLayout.LayoutParams imgParams = (RelativeLayout.LayoutParams) mImgCardView .getLayoutParams() ;
imgParams.addRule(RelativeLayout. ALIGN_PARENT_TOP , 0 ) ;
imgParams.addRule(RelativeLayout. BELOW , mlColumnCardView .getId()) ;
mImgCardView .setLayoutParams (imgParams) ;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325808549&siteId=291194637